Compiles SQL queries with named placeholders (:name) to unnamed positional parameterized queries (?) with a separate array of values. Version 1.1.7 (April 2026) is current; maintained under mysqljs organization on GitHub. Key differentiator: lightweight, zero-dependency solution for converting named placeholders in SQL strings for use with mysql/mysql2 or any ?-based driver. Handles nested quotes and escape sequences properly. Active development with frequent bug fixes.
npm install named-placeholdersNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: import factory, call it to get compiler, invoke with query and parameters object, then use resulting array with mysql/mysql2.
const compile = toUnnamed(); const [sql, vals] = compile(query, params);
Remember the order is sequential occurrence in the query, not object key order.
Update calls to pass optional config object as third argument if needed.
Use import toUnnamed from 'named-placeholders' then call toUnnamed()
const compile = toUnnamed(); // call factory first
const compile = toUnnamed();
const [sql, params] = compile('SELECT :val', { val: 1 });Ensure placeholders are outside string literals or use proper escaping.
No dependency data recorded yet.