{"id":43429,"library":"node-entities","title":"node-entities","description":"A lightweight MySQL ORM for Node.js that mimics Mongoose-style chainable queries. Version 2.1.8 is the latest stable release. It operates on 'convention over configuration', deriving table mappings from model names. Supports CRUD operations, transactions, findOne, count, and complex queries via SQL object with and/join. Depends on underscore, x-flow, and node-mysql. Simpler than Sequelize or TypeORM but less feature-rich (no schema creation, migrations, or mapping config).","status":"active","version":"2.1.8","language":"javascript","source_language":"en","source_url":"https://github.com/miwoy/entities","tags":["javascript","mysql","orm","simple"],"install":[{"cmd":"npm install node-entities","lang":"bash","label":"npm"},{"cmd":"yarn add node-entities","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-entities","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Utility library for object/array manipulation","package":"underscore","optional":false},{"reason":"Asynchronous flow control","package":"x-flow","optional":false},{"reason":"MySQL database driver","package":"mysql","optional":false}],"imports":[{"note":"The module exports the factoryMaster object directly. ESM import not supported.","wrong":"","symbol":"master (factoryMaster)","correct":"const master = require('node-entities');"},{"note":"Returns a Factory constructor class.","wrong":"master.init({...}, {...}); // correct usage shown","symbol":"init","correct":"master.init(opts, models);"},{"note":"Factory class is returned by init, not directly on master before init.","wrong":"const factory = new master.Factory(); // only after init","symbol":"Factory","correct":"const Factory = master.init(opts, models); const factory = new Factory();"}],"quickstart":{"code":"const master = require('node-entities');\n\nconst models = {\n    user: function User() {\n        this.id = { type: Number };\n        this.name = { type: String };\n        this.email = { type: String };\n    }\n};\n\nconst Factory = master.init({\n    host: process.env.MYSQL_HOST || 'localhost',\n    port: process.env.MYSQL_PORT || 3306,\n    user: process.env.MYSQL_USER || 'root',\n    password: process.env.MYSQL_PASSWORD || '',\n    database: process.env.MYSQL_DATABASE || 'test'\n}, models);\n\nconst factory = new Factory();\n\n// Insert a user\nfactory.save('user', { name: 'Alice', email: 'alice@example.com' }, function(err, result) {\n    if (err) console.error(err);\n    else console.log('Inserted user ID:', result.insertId);\n\n    // Query users\n    factory.find('user', {}, {}, function(err, users) {\n        if (err) console.error(err);\n        else console.log('Users:', users);\n    });\n});","lang":"javascript","description":"Shows initialization, model definition, insert, and query using node-entities."},"warnings":[{"fix":"Use factory.findOne() when expecting a single object, or handle array result.","message":"find() always returns results as an array, even for a single record. Use findOne() for a single object.","severity":"gotcha","affected_versions":">=2.0"},{"fix":"Update code to use new Factory() after init. See quickstart.","message":"v2.0 changed the API: init now returns a Factory class instead of an object. The old master.create() method was removed.","severity":"breaking","affected_versions":">=2.0"},{"fix":"Define models as shown in documentation: function ModelName() { this.field = {type: Type}; }","message":"Models must be defined using a function constructor (e.g., function User() {...}) and properties assigned with this. Schema format is limited.","severity":"gotcha","affected_versions":">=2.0"},{"fix":"No immediate fix required, but plan to migrate away from underscore.","message":"Underscore dependency is outdated; consider using lodash or native functions.","severity":"deprecated","affected_versions":">=2.0"}],"env_vars":null,"search_vec":"'2.1.8':18 'and/join':49 'chainabl':15 'complex':43 'config':76 'configur':29 'convent':27 'count':41 'creation':72 'crud':37 'depend':50 'deriv':30 'entiti':3 'featur':68 'feature-rich':67 'findon':40 'flow':55 'javascript':77 'latest':21 'less':66 'lightweight':5 'map':32,75 'migrat':73 'mimic':11 'model':34 'mongoos':13 'mongoose-styl':12 'mysql':6,59,78 'name':35 'node':2,58 'node-ent':1 'node-mysql':57 'node.js':9 'object':47 'oper':25,38 'orm':7,79 'queri':16,44 'releas':23 'rich':69 'schema':71 'sequel':62 'simpl':80 'simpler':60 'sql':46 'stabl':22 'style':14 'support':36 'tabl':31 'transact':39 'typeorm':64 'underscor':52 'version':17 'via':45 'x':54 'x-flow':53","created_at":"2026-06-05T16:59:45.608215+00:00","updated_at":"2026-06-05T16:59:45.608215+00:00","problems":[{"fix":"npm install x-flow","cause":"Missing dependency x-flow. Not installed automatically.","error":"Cannot find module 'x-flow'"},{"fix":"Ensure you call master.init() to get Factory, then create instance: const factory = new Factory();","cause":"Factory not initialized correctly or factory object not created via new Factory()","error":"factory.find is not a function"},{"fix":"Check if result.insertId exists or use result.affectedRows for non-auto_increment tables.","cause":"Insert callback returns raw mysql result object; insertId is present only if table has auto_increment.","error":"Cannot read property 'insertId' of undefined"}],"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/miwoy/entities#readme","github":"https://github.com/miwoy/entities","docs":null,"changelog":null,"pypi":null,"npm":"node-entities","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-05","next_check":"2026-09-03","install_tag":null}}