{"id":18573907,"url":"https://github.com/basedwon/orm","last_synced_at":"2026-01-25T18:31:50.423Z","repository":{"id":203405961,"uuid":"701898758","full_name":"basedwon/orm","owner":"basedwon","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-23T03:43:34.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-02T23:29:42.304Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"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/basedwon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-10-07T22:30:18.000Z","updated_at":"2024-08-23T03:43:37.000Z","dependencies_parsed_at":"2023-11-07T12:29:47.356Z","dependency_job_id":"2e1c3f9e-1318-4369-9ee3-300c762ce6fb","html_url":"https://github.com/basedwon/orm","commit_stats":null,"previous_names":["basedwon/orm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/basedwon/orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basedwon","download_url":"https://codeload.github.com/basedwon/orm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Form/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28756442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T16:32:25.380Z","status":"ssl_error","status_checked_at":"2026-01-25T16:32:09.189Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11-06T23:13:22.194Z","updated_at":"2026-01-25T18:31:50.407Z","avatar_url":"https://github.com/basedwon.png","language":"JavaScript","readme":"# Orm\n\n[![npm](https://img.shields.io/npm/v/@plaindb/orm?style=flat\u0026logo=npm)](https://www.npmjs.com/package/@plaindb/orm)\n[![pipeline](https://gitlab.com/frenware/framework/plaindb/orm/badges/master/pipeline.svg)](https://gitlab.com/frenware/framework/plaindb/orm/-/pipelines)\n[![license](https://img.shields.io/npm/l/@plaindb/orm)](https://gitlab.com/frenware/framework/plaindb/orm/-/blob/master/LICENSE)\n[![downloads](https://img.shields.io/npm/dw/@plaindb/orm)](https://www.npmjs.com/package/@plaindb/orm) \n\n[![Gitlab](https://img.shields.io/badge/Gitlab%20-%20?logo=gitlab\u0026color=%23383a40)](https://gitlab.com/frenware/framework/plaindb/orm)\n[![Github](https://img.shields.io/badge/Github%20-%20?logo=github\u0026color=%23383a40)](https://github.com/basedwon/orm)\n[![Twitter](https://img.shields.io/badge/@basdwon%20-%20?logo=twitter\u0026color=%23383a40)](https://twitter.com/basdwon)\n[![Discord](https://img.shields.io/badge/Basedwon%20-%20?logo=discord\u0026color=%23383a40)](https://discordapp.com/users/basedwon)\n\nA simple, yet extensible Object-Relational Mapping (ORM) library that allows you to interact with any key-value databse like LevelDB or Redis. It provides a clean and well-structured JavaScript API for performing database operations like Create, Read, Update, Delete (CRUD), indexing, and query searches. The package extends on the `@basd/encoder` package and follows Object-Oriented Programming (OOP) and SOLID principles, making it easy to extend and adapt to various use cases.\n\n## Features\n\n- Lightweight and efficient.\n- Extensible architecture based on @basd/encoder.\n- Dynamic index management.\n- Query engine for advanced searching.\n- Aggregator for optimized database interactions.\n\n## Installation\n\nInstall the package with:\n\n```bash\nnpm install @plaindb/orm\n```\n\n## Usage\n\nFirst, import the `Orm` library.\n\n```js\nimport Orm from '@plaindb/orm'\n```\nor\n```js\nconst Orm = require('@plaindb/orm')\n```\n\n### Basic Example\n\nHere is a simple example to demonstrate CRUD operations using the ORM:\n\n```js\nconst orm = new Orm(storage, {\n  User: {\n    name: 'string',\n    age: 'number'\n  }\n})\n\n// Create\nconst user = await orm.create('User', {\n  name: 'John Doe',\n  age: 30\n})\n\n// Update\nawait orm.update('User', user.id, {\n  age: 31\n})\n\n// Read\nconst fetchedUser = await orm.read('User', user.id)\n\n// Delete\nawait orm.delete('User', user.id)\n```\n\n### Advanced Example\n\nThis package allows more advanced use-cases, like list handling and relationships:\n\n```js\nconst orm = new Orm(storage, {\n  User: {\n    name: 'string',\n    posts: '...Post'\n  },\n  Post: {\n    content: 'string'\n  }\n})\n\nconst user = await orm.create('User', {\n  name: 'John',\n  posts: [\n    { content: 'First Post' },\n    { content: 'Second Post' }\n  ]\n})\n```\n\n## Extending\n\nSince the library follows OOP principles, you can easily extend it. For example, to add a new query operation:\n\n```js\nclass CustomOrmModel extends OrmModel {\n  constructor(type, fields, config, codex) {\n    super(type, fields, config, codex)\n    // Custom logic\n  }\n  customFind(query) {\n    // Custom find logic\n  }\n}\n```\n\n### Configuration Options\n\nThe `Orm` constructor accepts a configuration object that includes the following options:\n\n- `classes`: Define custom classes for models, fields, lists, etc.\n- `parseField`: A function to parse field definitions.\n- `props`: Define id, created, and updated property names.\n\n## Documentation\n\n- [API Reference](/docs/api.md)\n\n### OrmModel\n\nThe `OrmModel` class encapsulates an entity type in the database. It allows you to perform CRUD operations, as well as indexing and searching.\n\n#### Methods\n\n- `create(data)`: Creates a new entity.\n- `update(id, update)`: Updates an existing entity by its ID.\n- `delete(id)`: Deletes an entity by its ID.\n- `read(id)`: Fetches an entity by its ID.\n\n### Orm\n\nThe `Orm` class serves as a manager for different types of models and contains utility methods for global operations.\n\n#### Methods\n\n- `create(type, data)`: Creates a new entity of a given type.\n- `update(type, id, update)`: Updates an existing entity of a given type.\n- `delete(type, id)`: Deletes an entity of a given type.\n- `read(type, id)`: Reads an entity of a given type.\n\n## Tests\n\nIn order to run the test suite, simply clone the repository and install its dependencies:\n\n```bash\ngit clone https://gitlab.com/frenware/framework/plaindb/orm.git\ncd orm\nnpm install\n```\n\nTo run the tests:\n\n```bash\nnpm test\n```\n\n## Contributing\n\nThank you! Please see our [contributing guidelines](/docs/contributing.md) for details.\n\n## Donations\n\nIf you find this project useful and want to help support further development, please send us some coin. We greatly appreciate any and all contributions. Thank you!\n\n**Bitcoin (BTC):**\n```\n1JUb1yNFH6wjGekRUW6Dfgyg4J4h6wKKdF\n```\n\n**Monero (XMR):**\n```\n46uV2fMZT3EWkBrGUgszJCcbqFqEvqrB4bZBJwsbx7yA8e2WBakXzJSUK8aqT4GoqERzbg4oKT2SiPeCgjzVH6VpSQ5y7KQ\n```\n\n## License\n\n@plaindb/orm is [MIT licensed](https://gitlab.com/frenware/framework/plaindb/orm/-/blob/master/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedwon%2Form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasedwon%2Form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedwon%2Form/lists"}