Registry / database / syncorm

syncorm

JSON →
library0.1.54jsnpmunverified

Synchronous ORM for Node.js that loads the entire MySQL database into memory at startup, providing direct JavaScript object access and in-memory manipulation with transactional writes. Version 0.1.54 (last updated ~2016, no recent releases), mostly maintenance status. Key differentiators: synchronous operations (no callbacks/promises), full in-memory caching, one-to-many relations via object linking. Not suitable for large datasets due to memory constraints.

npm install syncorm
INSTALL
IMPORT
SIG · SYNCORM
S
syncorm
databasejavascriptv0.1.54
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Database
const { Database } = require('syncorm');
const Database = require('syncorm');
CommonJS require style; named export Database is the main class.
syncorm
const syncorm = require('syncorm');
import syncorm from 'syncorm';
ESM import not supported; package uses CommonJS with no default export.
sequence
const seq = db.sequences.name;
const seq = db.sequence.name;
Refers to the 'sequences' table; property name 'sequences' is plural.

Creates a database connection, defines a 'Person' table with fields and a calculated age field, then loads data synchronously.

const { Database } = require('syncorm'); const db = new Database({ driver: 'mysql', host: process.env.DB_HOST ?? '127.0.0.1', port: 3306, user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'syncorm_tutorial', log: true }); db.define({ name: 'Person', table: 'persons', id: 'idperson', fields: { idperson: { type: 'integer', def: () => db.sequences.idperson.inc() }, firstname: 'string', lastname: 'string', birthdate: 'date' }, calculatedFields: { age: function() { const today = new Date(); const birthDate = new Date(this.birthdate); let age = today.getFullYear() - birthDate.getFullYear(); const m = today.getMonth() - birthDate.getMonth(); if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) age--; return age; } }, triggers: [{ add: (record) => console.log('Added:', record) }] }); db.load(() => { // Now all data is in memory console.log(db.Person[1]); // Access by primary key // db.Person is a hash map });
Debug
Known issues
breakingSynchronous load: db.load() is blocking and will halt Node.js event loop until all data is loaded. Do not use with large datasets or production high-availability servers.
fix
Design the application to load once at startup; avoid loading during request handling.
affects: >=0.0.0
deprecatedPackage has not been updated since 2016. No support for MySQL 8.x's new features or modern JavaScript (ESM, async/await).
fix
Consider migrating to an up-to-date ORM like Sequelize, TypeORM, or Prisma.
affects: <=0.1.54
gotchaTriggers are called synchronously and can cause stack overflow if they recursively trigger other operations.
fix
Avoid modifying records inside triggers. Keep trigger logic minimal and side-effect free.
affects: >=0.0.0
gotchaDatabase is loaded entirely into memory; memory usage scales with database size. Very large tables can crash the process.
fix
Use for small datasets only (<100k records). For larger data, use a streaming ORM instead.
affects: >=0.0.0
breakingThe package does not support connection pooling; a single connection is used per Database instance.
fix
Instantiate only one Database object per process. For multiple databases, create separate instances.
affects: >=0.0.0
Errors
Common errors & fixes
Error: connect ECONNREFUSED 127.0.0.1:3306
MySQL server is not running or not accessible at the given host/port
fix
Start the MySQL service or update the Database config with the correct connection parameters.
Error: Cannot find module 'syncorm'
Package not installed or not found in node_modules
fix
Run 'npm install syncorm'
TypeError: Cannot read property 'Person' of undefined
Calling db.Person before the database is loaded (db.load callback not executed)
fix
Ensure all access to db.<table> happens inside the callback to db.load()
Error: ER_BAD_FIELD_ERROR: Unknown column 'idperson' in 'field list'
The table definition field name does not match the actual column name in MySQL
fix
Verify that the 'id' and 'fields' keys in define() match the exact column names in your MySQL table.
Upgrade
Version history
0.1.54latest on npm
Audit
Dependencies
mysqlrequiredMySQL driver for database connectivity
lodashoptionalRecommended for traversing linked objects
Agent activity
19 hits · last 30 days
node
14
Meta
2
OpenAI (training)
1
Resources
syncorm — npm install syncorm · libregistry