mybatis-mapper generates SQL statements from MyBatis3 Mapper XML files in Node.js. Version 0.8.0 supports all MyBatis dynamic SQL elements including <if>, <choose>, <where>, <foreach>, <bind>, and <include>. It parses mapper XML files with namespaces and provides methods to build parameterized SQL queries using #{...} and ${...} syntax. Different from ORM-based libraries, it focuses on reusing existing MyBatis XML mappings in Node.js environments. The library integrates with sql-formatter for output formatting. Compatible with MySQL clients like mysql2.
npm install mybatis-mapperNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows loading a MyBatis XML mapper, building a SQL statement with parameters, and executing it via mysql2/promise.
Wrap the file path in an array: ['file.xml'].
Prefer #{} for parameter binding. Use ${} only with trusted values.Use require() or await import('mybatis-mapper') with dynamic import.Provide { language: 'sql', indent: ' ' } at minimum.Call getStatement('namespace', 'sqlId', ...) not getStatement('namespace.sqlId', ...).Run 'npm install mybatis-mapper --save'.
Use 'const mybatisMapper = require('mybatis-mapper')' then call 'mybatisMapper.createMapper'.Provide a format object with 'language' and 'indent' properties, e.g., { language: 'sql', indent: ' ' }.Call getStatement('namespace', 'sqlId', ...) with two separate string arguments.