{"id":42054,"library":"syncorm","title":"syncorm","description":"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.","status":"maintenance","version":"0.1.54","language":"javascript","source_language":"en","source_url":"https://github.com/jbaylina/syncorm","tags":["javascript","orm","database","mysql","object","mapping"],"install":[{"cmd":"npm install syncorm","lang":"bash","label":"npm"},{"cmd":"yarn add syncorm","lang":"bash","label":"yarn"},{"cmd":"pnpm add syncorm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"MySQL driver for database connectivity","package":"mysql","optional":false},{"reason":"Recommended for traversing linked objects","package":"lodash","optional":true}],"imports":[{"note":"CommonJS require style; named export Database is the main class.","wrong":"const Database = require('syncorm');","symbol":"Database","correct":"const { Database } = require('syncorm');"},{"note":"ESM import not supported; package uses CommonJS with no default export.","wrong":"import syncorm from 'syncorm';","symbol":"syncorm","correct":"const syncorm = require('syncorm');"},{"note":"Refers to the 'sequences' table; property name 'sequences' is plural.","wrong":"const seq = db.sequence.name;","symbol":"sequence","correct":"const seq = db.sequences.name;"}],"quickstart":{"code":"const { Database } = require('syncorm');\n\nconst db = new Database({\n  driver: 'mysql',\n  host: process.env.DB_HOST ?? '127.0.0.1',\n  port: 3306,\n  user: process.env.DB_USER ?? 'root',\n  password: process.env.DB_PASS ?? '',\n  database: process.env.DB_NAME ?? 'syncorm_tutorial',\n  log: true\n});\n\ndb.define({\n  name: 'Person',\n  table: 'persons',\n  id: 'idperson',\n  fields: {\n    idperson: { type: 'integer', def: () => db.sequences.idperson.inc() },\n    firstname: 'string',\n    lastname: 'string',\n    birthdate: 'date'\n  },\n  calculatedFields: {\n    age: function() {\n      const today = new Date();\n      const birthDate = new Date(this.birthdate);\n      let age = today.getFullYear() - birthDate.getFullYear();\n      const m = today.getMonth() - birthDate.getMonth();\n      if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) age--;\n      return age;\n    }\n  },\n  triggers: [{ add: (record) => console.log('Added:', record) }]\n});\n\ndb.load(() => {\n  // Now all data is in memory\n  console.log(db.Person[1]); // Access by primary key\n  // db.Person is a hash map\n});","lang":"javascript","description":"Creates a database connection, defines a 'Person' table with fields and a calculated age field, then loads data synchronously."},"warnings":[{"fix":"Design the application to load once at startup; avoid loading during request handling.","message":"Synchronous 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.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Consider migrating to an up-to-date ORM like Sequelize, TypeORM, or Prisma.","message":"Package has not been updated since 2016. No support for MySQL 8.x's new features or modern JavaScript (ESM, async/await).","severity":"deprecated","affected_versions":"<=0.1.54"},{"fix":"Avoid modifying records inside triggers. Keep trigger logic minimal and side-effect free.","message":"Triggers are called synchronously and can cause stack overflow if they recursively trigger other operations.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use for small datasets only (<100k records). For larger data, use a streaming ORM instead.","message":"Database is loaded entirely into memory; memory usage scales with database size. Very large tables can crash the process.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Instantiate only one Database object per process. For multiple databases, create separate instances.","message":"The package does not support connection pooling; a single connection is used per Database instance.","severity":"breaking","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.1.54':30 '2016':33 'access':20 'cach':50 'callbacks/promises':45 'constraint':67 'databas':11,70 'dataset':63 'differenti':41 'direct':17 'due':64 'entir':9 'full':46 'in-memori':22,47 'javascript':18,68 'key':40 'larg':62 'last':31 'link':58 'load':7 'mainten':38 'mani':54 'manipul':25 'map':73 'memori':13,24,49,66 'most':37 'mysql':10,71 'node.js':5 'object':19,57,72 'one':52 'one-to-mani':51 'oper':43 'orm':3,69 'provid':16 'recent':35 'relat':55 'releas':36 'startup':15 'status':39 'suitabl':60 'synchron':2,42 'syncorm':1 'transact':27 'updat':32 'version':29 'via':56 'write':28","created_at":"2026-06-04T18:55:23.718850+00:00","updated_at":"2026-06-04T18:55:23.718850+00:00","problems":[{"fix":"Start the MySQL service or update the Database config with the correct connection parameters.","cause":"MySQL server is not running or not accessible at the given host/port","error":"Error: connect ECONNREFUSED 127.0.0.1:3306"},{"fix":"Run 'npm install syncorm'","cause":"Package not installed or not found in node_modules","error":"Error: Cannot find module 'syncorm'"},{"fix":"Ensure all access to db.<table> happens inside the callback to db.load()","cause":"Calling db.Person before the database is loaded (db.load callback not executed)","error":"TypeError: Cannot read property 'Person' of undefined"},{"fix":"Verify that the 'id' and 'fields' keys in define() match the exact column names in your MySQL table.","cause":"The table definition field name does not match the actual column name in MySQL","error":"Error: ER_BAD_FIELD_ERROR: Unknown column 'idperson' in 'field list'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/jbaylina/syncorm#readme","github":"https://github.com/jbaylina/syncorm","docs":null,"changelog":null,"pypi":null,"npm":"syncorm","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}