{"id":18929249,"url":"https://github.com/fractalerp/active-record-js","last_synced_at":"2026-02-17T02:36:59.589Z","repository":{"id":252424719,"uuid":"840240073","full_name":"fractalerp/active-record-js","owner":"fractalerp","description":"A library responsible for representing business data.  This library follows the Active Record Pattern by building a wrapper on top of popular orm such as Mongoose and Sequelize to support all kinds of databases","archived":false,"fork":false,"pushed_at":"2025-03-31T05:44:35.000Z","size":1835,"stargazers_count":1,"open_issues_count":11,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-19T15:39:01.172Z","etag":null,"topics":["active-record","active-record-design-pattern","database","mongodb","moongoose","orm","orm-framework","sequelize"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/fractalerp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2024-08-09T09:12:09.000Z","updated_at":"2025-01-06T23:28:33.000Z","dependencies_parsed_at":"2024-09-06T16:40:52.376Z","dependency_job_id":"1676a6e6-0bc9-4bcb-abf3-0b79e4b6034f","html_url":"https://github.com/fractalerp/active-record-js","commit_stats":null,"previous_names":["fractalerp/active-record-js"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/fractalerp/active-record-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractalerp%2Factive-record-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractalerp%2Factive-record-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractalerp%2Factive-record-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractalerp%2Factive-record-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fractalerp","download_url":"https://codeload.github.com/fractalerp/active-record-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractalerp%2Factive-record-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018582,"owners_count":26086583,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["active-record","active-record-design-pattern","database","mongodb","moongoose","orm","orm-framework","sequelize"],"created_at":"2024-11-08T11:31:23.818Z","updated_at":"2025-10-14T12:57:31.657Z","avatar_url":"https://github.com/fractalerp.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Node.js CI](https://github.com/fractalerp/active-record-js/actions/workflows/ci.yml/badge.svg)](https://github.com/fractalerp/active-record-js/actions/workflows/ci.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/486b143d9023a951f36d/maintainability)](https://codeclimate.com/github/fractalerp/active-record-js/maintainability)\n[![Dependencies](https://img.shields.io/librariesio/release/npm/@fractalerp/active-record-js)](https://libraries.io/npm/@fractalerp%2Factive-record-js)\n[![Vulnerabilities](https://snyk.io/test/github/fractalerp/active-record-js/badge.svg)](https://snyk.io/test/github/fractalerp/active-record-js)\n![Node 11](https://img.shields.io/badge/node-11.5.x-green.svg)\n![Npm 6](https://img.shields.io/badge/npm-6.4.x-green.svg)\n![Webpack 5](https://img.shields.io/badge/webpack-5.20.2-green.svg)\n[![codecov](https://codecov.io/gh/fractalerp/active-record-js/branch/main/graph/badge.svg)](https://codecov.io/gh/fractalerp/active-record-js)\n[![Coverage Status](https://coveralls.io/repos/github/fractalerp/active-record-js/badge.svg?branch=main)](https://coveralls.io/github/fractalerp/active-record-js?branch=main)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat-square)](https://github.com/fractalerp/active-record-js/issues)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n[![code style: Eslint](https://img.shields.io/badge/eslint_rules-%5E9.9.0-ff69b4.svg?style=flat-square)](https://eslint.org)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Ffractalerp%2Factive-record-js.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Ffractalerp%2Factive-record-js?ref=badge_shield)\n[![MIT](https://img.shields.io/badge/mit-blue.svg)](http://opensource.org/licenses/mit)\n\n[![npm](https://nodei.co/npm/@fractalerp/active-record-js.png)](https://www.npmjs.com/package/@fractalerp/active-record-js)\n\n[![Download Status](https://img.shields.io/npm/dt/@fractalerp/active-record-js.svg)](https://www.npmjs.com/package/@fractalerp/active-record-js)\n\n# ACTIVE RECORD JS\nA library responsible for representing business data. \n\nThis library follows the `Active Record Pattern` by building a wrapper on top of popular orm such as [Mongoose](https://www.npmjs.com/package/mongoose) and [Sequelize](https://www.npmjs.com/package/sequelize) to support all kinds of databases\n\n## ⚙️ How to use the package in project\n1. You should create the following environment variables in your node project.\n```env\nRDBMS_DATABASE_URI=\"mysql://DATBASE_USER:DATABASE_PASSWORD@DATABASE_HOST:DATABASE_PORT/DATABASE_DB\"\nNOSQL_DATABASE_URI=\"mongodb://DATABASE_HOST:DATABASE_PORT/DATABASE_DB\"\nNOSQL_DATABASE_ADAPTER=\"mongodb\"\n```\n2. Once the variables have been set. You should create a model base on the active record `SchemaProperty`. See example below\n\n```typescript\nimport { ActiveRecord } from \"@fractalerp/active-record-js\"\n\nexport interface ITaskModelDocument {\n  name: string;\n  description: string;\n}\n\nconst TaskModelSchema = {\n  name: {\n    type: String,\n    required: true,\n    unique: true\n  },\n  description: {\n    type: String,\n    default: null\n  }\n};\n\nexport const TaskModel = new ActiveRecord\u003cITaskModelDocument\u003e(\"Task\", TaskModelSchema);\n\n```\n3. Then use its methods to perform data management. The following methods are supported;\n\n|Method|Description|\n|------------------|-----------|\n|`find`|returns list of data objects|\n|`findOne`|returns one data item|\n|`create`|save item to the data store|\n|`update`|updates the record in the store|\n|`delete`|delete item from the data store|\n\nSince we support all kinds of databases. The following are the respective methods of the two kinds of databases.\n\nThis only applies to `NOSQL databases`\n\n|Method|Description|\n|------------------|-----------|\n|`aggregate`|peform aggregate action based on a pipeline|\n|`index`|create an index in the document store|\n\nThis only applies to `Relational databases`\n\n|Method|Description|\n|------------------|-----------|\n|`query`|create a raw `SQL` to send to database|\n|`beginTransaction`|start a transaction|\n|`commitTransaction`|persist a transaction|\n|`rollbackTransaction`|rollback a transaction|\n\nOther than that, all the other ORM respective methods for `Sequelize` and `Mongoose` are supported by default.\n\n4. Finally you can use the model to peform data action. See example.\n\n```typescript\n// create task\nconst task = await TaskModel.create({\n    name: 'Use fractalerp active record js',\n    description: 'Change all models'\n});\n\n// Find one task\nconst task = await TaskModel.findOne({ id: 'cbdabs-29232323-msasd'});\n```\n\n5. You can also use the underlying ORM model and instance methods\n\n```typescript\n// create task\nconst filter = { };\nconst countTasks = await TaskModel.model.countDocuments(filter);\n\n```\n\n## 🫶 Projects using this package\nSee the projects using this package in action.\n- [Fractal Js](https://github.com/fractalerp/fractal-js)\n- [Fractalerp core](https://github.com/fractalerp/fractal-core)\n\n## 🪲 Issues, suggestions and feature requests\n\nWe are actively maintaining this library, please report any issues or suggestion for improvement at https://github.com/fractalerp/active-record-js/issues\n\n## 👩‍💻 Development and contribution\nPrerequisite: Install git, node package manager, webpack CLI, grunt CLI\n\nTo contribute, fork and clone.\n\n    \u003e git clone https://github.com/fractalerp/active-record-js.git\n\nThe code is in typescript. Use a typescript IDE of your choice, like Visual Studio Code or WebStorm.\n\nTo set up the development environment, run:\n\n    \u003e npm install\n\nTo automatically compile, bundle and push code changes to the running test project, run:\n\n    \u003e npm start\n\nTo run the project unit tests with code coverage, results can be found at `dist/testresults/coverage/index.html`, run:\n\n    \u003e npm run test:unit\n\nRun the unit test continuously during development:\n\n    \u003e npm run test:dev\n\n## Scripts\nWhile developing, you will probably rely mostly on `npm start`; however, there are additional scripts at your disposal:\n\n|`npm run \u003cscript\u003e`|Description|\n|------------------|-----------|\n|`start`|Build the project and monitor source and config for changes and rebuild. Start the dev server|\n|`watch`|Build the project and monitor source and config for changes and rebuild.|\n|`emit`|Output javascript code|\n|`test`|Runs lint, build, unit tests with mocha and generates a coverage report|\n|`test:dev`|Runs mocha and watches for changes to re-run tests; does not generate coverage reports.|\n|`test:unit`|Runs unit tests with mocha and generates a coverage report.|\n|`build:release`|Build app optimized for production|\n|`build:development`|Build app optimized for debugging.|\n|`lint`|Lint all `.js` files.|\n|`lint:fix`|Lint and fix all `.ts` files.|\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffractalerp%2Factive-record-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffractalerp%2Factive-record-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffractalerp%2Factive-record-js/lists"}