sql-mapper is a Node.js SQL mapper library inspired by MyBatis, providing a template-based approach to write SQL queries in XML or JS object format. Version 1.2.1 is the latest stable release. It allows dynamic SQL generation with conditions, loops, and fragments, similar to MyBatis. Different from ORMs like Sequelize, it gives full control over SQL while reducing boilerplate. The package is lightweight, with no production dependencies, and supports both CommonJS and ESM via bundlers.
npm install sql-mapperNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic setup: create mapper, define a dynamic SQL template, and execute with parameters.
Use `sqlMapper.create()` instead of `sqlMapper.createMapper()`.
Always use `#{paramName}` syntax for parameters, and `<#if condition>...</#if>` for conditionals.Install a database driver and pass connection config to `create()` or define in mapper.
Use `sqlMapper.create()` with SQL string templates instead of XML files.
Run `npm install sql-mapper` and ensure import is correct: `import sqlMapper from 'sql-mapper'`.
Use `#{param}` for placeholders and `<#if condition> ... </#if>` for conditionals.Pass connection configuration to `create()` or set up a global connection pool.
Update to latest version (1.2.1) and use `sqlMapper.create().define(...)`.
No dependency data recorded yet.