MasterRecord is a lightweight, code-first Object-Relational Mapper (ORM) for Node.js, currently at version 1.0.4. It emphasizes a fluent, lambda-based query API, a comprehensive CLI-driven migration system, and out-of-the-box support for multiple relational databases including MySQL (5.7+/8.0+), PostgreSQL (9.6+/12+), and SQLite (3.x). The ORM operates on an Active Record pattern, providing entity serialization, lifecycle hooks, and built-in validation. A key differentiator is its "ESM only" nature, requiring Node.js 20+ and a host project configured as a module, with no CommonJS build available. It offers features like query result caching, bulk operations, and robust SQL injection protection through parameterized queries. The project seems to follow a stable release cadence with its initial major v1.0 release.
npm install masterrecordVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure MasterRecord with an SQLite database, define a `User` entity, sync the schema, and perform basic CRUD operations (create, save, query) on entity instances.
Ensure Node.js >=20.0.0 is installed and your project's `package.json` has `"type": "module"`. Update import statements to use ESM syntax (e.g., `import { MasterRecord } from 'masterrecord';`).Always use `const newEntity = MasterRecord.create(YourEntityClass, { ...data });` to ensure full ORM functionality and adherence to defined business logic and lifecycle processes.Prioritize using MasterRecord's fluent query builder for all data operations. If raw SQL is absolutely necessary, rigorously validate and sanitize all user-supplied input and utilize parameterized queries diligently.
For production deployments, utilize the MasterRecord CLI to generate and run migrations (`masterrecord migrate up`, `masterrecord migrate down`) to manage schema changes in a controlled and versioned manner.
Ensure your project's `package.json` has `"type": "module"` and use `import { ... } from 'masterrecord';` syntax. Upgrade your Node.js environment to version 20.0.0 or newer.Upgrade your Node.js environment to version 20.0.0 or newer. Consider using a version manager like `nvm` or `volta` to manage Node.js versions.
Always ensure you are correctly importing `MasterRecord` and using the factory method as `const newEntity = MasterRecord.create(YourEntityClass, { data });`.Verify that your database server is running and accessible. Double-check all connection parameters in your `MasterRecord.configure()` settings. Ensure no firewalls are blocking the connection. For SQLite, check the `filename` path and file system permissions.
No dependency data recorded yet.