{"id":43476,"library":"nodebatis","title":"NodeBatis","description":"NodeBatis is a SQL-style ORM for Node.js, inspired by MyBatis on Java. It allows developers to write SQL statements in YAML files and execute them via namespaced keys. Version 2.4.2 is the latest stable release, compatible with Node >=7.6.0. It currently supports only MySQL. Key differentiators include first-class SQL support, parameter binding with :paramName, DDL support with ::ddl, SQL inheritance via {{namespace.key}}, conditional SQL fragments (if), and for-loop SQL generation for batch operations. It also offers transaction management and connection pooling. Compared to traditional ORMs like Sequelize or TypeORM, NodeBatis gives full control over SQL, avoiding ORM abstraction overhead.","status":"active","version":"2.4.2","language":"javascript","source_language":"en","source_url":"https://github.com/PeterMu/nodebatis","tags":["javascript","nodebatis","orm","sql","mybatis"],"install":[{"cmd":"npm install nodebatis","lang":"bash","label":"npm"},{"cmd":"yarn add nodebatis","lang":"bash","label":"yarn"},{"cmd":"pnpm add nodebatis","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import from ESM. CommonJS require also works but is non-standard.","wrong":"const NodeBatis = require('nodebatis')","symbol":"NodeBatis","correct":"import NodeBatis from 'nodebatis'"},{"note":"Required to resolve YAML directory path.","wrong":"","symbol":"path","correct":"import path from 'path'"},{"note":"YAML directory must be an absolute path. Use path.resolve.","wrong":"const nodebatis = new NodeBatis('./yaml', config)","symbol":"nodebatis instance","correct":"const nodebatis = new NodeBatis(path.resolve(__dirname, './yaml'), config)"}],"quickstart":{"code":"import NodeBatis from 'nodebatis';\nimport path from 'path';\n\nconst nodebatis = new NodeBatis(path.resolve(__dirname, './yaml'), {\n  debug: true,\n  dialect: 'mysql',\n  host: '127.0.0.1',\n  port: 3306,\n  database: 'test',\n  user: 'root',\n  password: process.env.DB_PASSWORD ?? 'root'\n});\n\nasync function findByAge(age) {\n  const result = await nodebatis.execute('test.findByAge', { age });\n  return result;\n}\n\nfindByAge(18).then(rows => console.log(rows));","lang":"typescript","description":"Initialize NodeBatis with MySQL config, execute a named query from YAML, and handle results asynchronously."},"warnings":[{"fix":"Use path.resolve(__dirname, 'yaml') or an absolute path string.","message":"YAML directory must be an absolute path; relative paths may fail silently","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Set dialect: 'mysql' or wait for future versions.","message":"Only MySQL dialect is supported; attempts to use other dialects will throw errors","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use :paramName in SQL and pass an object with matching keys.","message":"Parameter binding uses :paramName syntax, not ? or $1","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Upgrade Node to >=7.6.0 or use an older NodeBatis version (not recommended).","message":"Node <7.6.0 is not supported; old versions (<=2.2.1) are deprecated","severity":"deprecated","affected_versions":"<=2.2.1"}],"env_vars":null,"search_vec":"'2.4.2':33 '7.6.0':42 'abstract':105 'allow':17 'also':82 'avoid':103 'batch':79 'bind':57 'class':53 'compar':89 'compat':39 'condit':68 'connect':87 'control':100 'current':44 'ddl':60,63 'develop':18 'differenti':49 'execut':27 'file':25 'first':52 'first-class':51 'for-loop':73 'fragment':70 'full':99 'generat':77 'give':98 'includ':50 'inherit':65 'inspir':11 'java':15 'javascript':107 'key':31,48 'latest':36 'like':93 'loop':75 'manag':85 'mybati':13,111 'mysql':47 'namespac':30 'namespace.key':67 'node':41 'node.js':10 'nodebati':1,2,97,108 'offer':83 'oper':80 'orm':8,92,104,109 'overhead':106 'paramet':56 'paramnam':59 'pool':88 'releas':38 'sequel':94 'sql':6,21,54,64,69,76,102,110 'sql-style':5 'stabl':37 'statement':22 'style':7 'support':45,55,61 'tradit':91 'transact':84 'typeorm':96 'version':32 'via':29,66 'write':20 'yaml':24","created_at":"2026-06-05T16:59:59.296544+00:00","updated_at":"2026-06-05T16:59:59.296544+00:00","problems":[{"fix":"Run: npm install nodebatis --save","cause":"nodebatis not installed or missing from package.json","error":"Error: Cannot find module 'nodebatis'"},{"fix":"Provide an absolute path using path.resolve(__dirname, './yaml')","cause":"YAML directory path is invalid or relative","error":"Error: ENOENT: no such file or directory, open '...'"},{"fix":"Change config.dialect to 'mysql'","cause":"Only 'mysql' is supported as dialect","error":"Error: Dialect 'postgresql' is not supported"}],"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/PeterMu/nodebatis","github":"https://github.com/PeterMu/nodebatis","docs":null,"changelog":null,"pypi":null,"npm":"nodebatis","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}}