{"id":13672763,"url":"https://github.com/knyga/light-orm","last_synced_at":"2026-01-05T01:18:57.842Z","repository":{"id":13547528,"uuid":"16239484","full_name":"knyga/light-orm","owner":"knyga","description":"Simple ORM node.js wrapper for relational databases. It do not depends on any specific driver, so you can connect to mysql, ms server and so on","archived":false,"fork":false,"pushed_at":"2023-03-28T16:43:56.000Z","size":72,"stargazers_count":32,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-11T11:44:55.924Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knyga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-01-25T20:43:42.000Z","updated_at":"2023-09-27T19:51:01.000Z","dependencies_parsed_at":"2024-01-17T04:18:35.675Z","dependency_job_id":null,"html_url":"https://github.com/knyga/light-orm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knyga%2Flight-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knyga%2Flight-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knyga%2Flight-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knyga%2Flight-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knyga","download_url":"https://codeload.github.com/knyga/light-orm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251246394,"owners_count":21558762,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T09:01:46.895Z","updated_at":"2026-01-05T01:18:57.813Z","avatar_url":"https://github.com/knyga.png","language":"TypeScript","readme":"## Light-orm\nLight-orm - simple ORM node.js wrapper for relational databases. It does not depends on any specific driver, so you can connect to mysql, postgresql, ms server with your favorite driver.\n\nYour db connector (or wrapper) just should implement the interface:\n```\ninterface DriverInterface {\n    query(query: string, handler: (err, rows, fields) =\u003e void);\n}\n```\nThis interface came from node-mysql driver, as most popular option, that lets you avoid writting your wrappers to connectors.\n\nLight-orm gives you freedom in choising your own driver. You should not any more make meet half-way between high driver performance with native realization and ORM wrapper.\n\n### Installation\n`npm install light-orm`\n\n### Development\nLight-orm is written on typescript. Look for the sources here: lib/typescript and lib/compiler. You may find there comments in jsdoc style.\n\n### Examples\nExample connection (mysql):\n```javascript\nvar mysql = require('mysql'),\n\tlightOrm = require('light-orm');\n\nlightOrm.driver = mysql.createConnection(require('./connection.json'));\nlightOrm.driver.connect();\n```\n\nCreate collection for table name `author`:\n```javascript\nvar AuthorCollection = new lightOrm.Collection('author');\n```\n\nFind one model:\n```javascript\nAuthorCollection.findOne({\n\tid: 1\n}, function(err, model) {\n\tconsole.log(model.getAll());\n\t//{ id: 1, name: 'James Bond', description: 'Agent 007' }\n});\n```\n\nFind one model by sql:\n```javascript\nAuthorCollection.findOne(\"SELECT * FROM `author` WHERE id = 1\", function(err, model) {\n\tconsole.log(model.getAll());\n\t//{ id: 1, name: 'James Bond', description: 'Agent 007' }\n});\n```\n\nFind models:\n```javascript\nCarCollection.find({\n\tcategory_id: 5\n}, function(err, models) {});\n```\n\nFind models by sql:\n```javascript\nCarCollection.find({\n\tcategory_id: 5\n}, function(err, models) {});\n```\n\nGet all attributes:\n```javascript\nmodel.getAll();\n```\n\nGet one attribute:\n```javascript\nmodel.get('name');\n```\n\nSet attribute:\n```javascript\nmodel.set('name', 'Oleksandr Knyga');\n```\n\nSet attributes:\n```javascript\nmodel.set({\n\tname: 'Oleksandr Knyga'\n});\n```\n\nCheck attribute:\n```javascript\nmodel.has('name');\n```\n\nClear attributes:\n```javascript\nmodel.clear();\n```\n\nClear one attribute:\n```javascript\nmodel.clear('name');\n```\n\nGet custom row by sql:\n```javascript\nAuthorCollection.findOne(\"SELECT COUNT(*) as `count` FROM `author` WHERE name = '\" + author.name + \"'\", function(err, data) {\n\tvar count = data.get('count');\n});\n```\n\nSave:\n```javascript\nmodel.create(function(err, model) {});\n```\n\nUpdate:\n```javascript\nmodel.update(function(err, model) {});\n```\n\nUpdate, with custom where block:\n```javascript\nmodel.update({\n\tpkValue: {\n\t\tid: 31\n\t}\n}, function(err, model) {});\n```\n\nUpdate, manual pk field name:\n```javascript\nmodel.update({\n\t\tpk: ['id']\n}, function(err, model) {});\n```\n\nDelete:\n```javascript\nmodel.remove(function(err, model) {});\n```\n\nDelete, with custom where block:\n```javascript\nmodel.remove({\n\tpkValue: {\n\t\tid: 31\n\t}\n}, function(err, model) {});\n```\n\nDelete, manual pk field name:\n```javascript\nmodel.remove({\n\t\tpk: ['id']\n}, function(err, model) {});\n```\n\nIf you do not want to have model in callback, add `false` as last argument to remove, update, create. Like this:\n```javascript\nmodel.update({\n\tpkValue: {\n\t\tid: 31\n\t}\n}, function(err, model) {}, false);\n```\n\n### Licence\nCopyright 2014 Oleksandr Knyga \u003coleksandrknyga@gmail.com\u003e\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknyga%2Flight-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknyga%2Flight-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknyga%2Flight-orm/lists"}