{"id":15890177,"url":"https://github.com/hph/ormur","last_synced_at":"2025-03-20T11:35:47.037Z","repository":{"id":57316353,"uuid":"53527958","full_name":"hph/ormur","owner":"hph","description":"A simple, sane \u0026 modern ORM library for Node.js","archived":false,"fork":false,"pushed_at":"2016-03-29T21:54:24.000Z","size":24,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-13T07:41:01.362Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hph.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}},"created_at":"2016-03-09T20:06:08.000Z","updated_at":"2023-03-10T10:08:27.000Z","dependencies_parsed_at":"2022-08-25T21:11:04.028Z","dependency_job_id":null,"html_url":"https://github.com/hph/ormur","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/hph%2Formur","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hph%2Formur/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hph%2Formur/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hph%2Formur/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hph","download_url":"https://codeload.github.com/hph/ormur/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221752964,"owners_count":16875062,"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-10-06T07:04:21.225Z","updated_at":"2024-10-28T00:40:33.741Z","avatar_url":"https://github.com/hph.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ormur\n\n[![Package Version](https://img.shields.io/npm/v/ormur.svg)](https://www.npmjs.com/package/ormur) [![Build Status](https://travis-ci.org/hph/ormur.svg?branch=master)](https://travis-ci.org/hph/ormur) [![Test Coverage](https://img.shields.io/codecov/c/github/hph/ormur.svg)](https://codecov.io/github/hph/ormur?branch=master) [![License](https://img.shields.io/npm/l/ormur.svg)](https://tldrlegal.com/license/mit-license)\n\n\u003e A simple, sane \u0026 modern ORM library for Node.js\n\n## Features\n\n- High extensibility and behaviour customization via inheritance.\n- Schema validation and custom field validations.\n- High-level query interface along with a [Knex](http://knexjs.org/) instance for custom queries.\n- Use promises instead of callbacks to interact with the database.\n- Default values and value transformations before creating records.\n- Automatic `snake_case` (for the database) and `camelCase` (for JavaScript) handling.\n- Safe JSON serialization by omitting private fields.\n\nAnd much more - see the example below to get an idea.\n\n## Install\n\nRequires Node.js v4.0.0 or higher.\n\n    npm install ormur\n\n## Examples\n\nCheck out the [basic example](https://github.com/hph/ormur/tree/master/example/basic)\nfor an example of a minimal base model and an example model inheriting from it.\n\nFor an example of how you may share schema between models, check the [advanced\nexample](https://github.com/hph/ormur/tree/master/example/advanced).\n\nThe `User` model defined in the above examples could be used like this,\nassuming that the relevant database table exists:\n\n```javascript\nconst User = require('./example/basic/user');\n\n// Create an instance\nconst user = new User({ name: 'Hawk', email: 'test@example.com', password: 'password' });\n\n// Persist it to the database\nuser.save().then(user =\u003e {\n  console.log(`User ${user.name} with id ${user.id} saved.`);\n});\n\n// Find users with the name \"Hawk\"\nUser.where({ name: 'Hawk' }).then(users =\u003e {\n  // Array of User instances.\n  console.log(users);\n});\n\n// Find a user by its primary key and remove it from the database\nUser.find(1).then(user =\u003e user.destroy());\n\n// Or, maybe more succintly\nUser.destroy(1);\n```\n\n## API\n\nDocumentation pending.\n\n### Static methods\n\n- `Ormur.find` - Find row by primary key.\n- `Ormur.where` - Find rows by attributes.\n- `Ormur.create` - Create row with attributes.\n- `Ormur.destroy` - Remove row by primary key.\n\n### Instance methods\n\n- `Ormur#validate` - Validate attributes.\n- `Ormur#save` - Insert row into database with attributes from instance.\n- `Ormur#update` - Update existing row in database with attributes from instance.\n- `Ormur#destroy` - Remove row from database by primary key of instance.\n- `Ormur#setDefaults` - Set default values to instance attributes.\n- `Ormur#merge` - Merge two objects (inheritance helper).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhph%2Formur","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhph%2Formur","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhph%2Formur/lists"}