Registry / storage / mysql-bricks

mysql-bricks

JSON →
library2.0.0jsnpmunverified

mysql-bricks extends sql-bricks to generate MySQL-specific SQL statements, such as INSERT ... ON DUPLICATE KEY UPDATE, INSERT IGNORE, LIMIT/OFFSET, and ORDER BY in UPDATE/DELETE. Version 2.0.0 requires Node.js 6+ and ESM. It is a thin wrapper around sql-bricks and has no additional runtime dependencies beyond sql-bricks. Compared to alternatives like knex or squel, mysql-bricks is minimal and focused solely on MySQL dialect support.

npm install mysql-bricks
INSTALL
IMPORT
SIG · MYSQL-BRICKS
M
mysql-bricks
storagejavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sql
import sql from 'mysql-bricks'
const sql = require('mysql-bricks')
Default import; library is ESM-only since v2. CommonJS require may fail depending on Node version.
SqlBricks
import SqlBricks from 'sql-bricks'
import { SqlBricks } from 'sql-bricks'
Named import is incorrect; sql-bricks uses a default export.
insert, select, update, delete
import sql from 'mysql-bricks'; sql.insert(...); sql.select(...)
import { insert, select } from 'mysql-bricks'
Functions are properties of the default export, not named exports.

Demonstrates MySQL-specific features: INSERT ... ON DUPLICATE KEY UPDATE with multiple rows, and SELECT with LIMIT/OFFSET.

import sql from 'mysql-bricks'; // INSERT ... ON DUPLICATE KEY UPDATE const values = [[1, 'Alice', 30], [2, 'Bob', 25]]; const query = sql.insert('users', 'id', 'name', 'age') .values(values) .onDuplicateKeyUpdate(['age']) .toString(); console.log(query); // INSERT INTO users (id, name, age) VALUES (1, 'Alice', 30), (2, 'Bob', 25) ON DUPLICATE KEY UPDATE age = VALUES(age) // SELECT with LIMIT and OFFSET const selectQuery = sql.select().from('orders').limit(10).offset(20).toString(); console.log(selectQuery); // SELECT * FROM orders LIMIT 10 OFFSET 20
Debug
Known issues
breakingVersion 2.0.0 drops support for Node.js <6 and may have changed module system (ESM). CommonJS require might not work.
fix
Use import syntax (ESM) or upgrade to Node.js 12+ with --experimental-modules or use bundler.
affects: >=2.0.0
gotchaON DUPLICATE KEY UPDATE with free-text SQL values will not be automatically quoted; reserved words may break.
fix
Manually quote identifiers or use column-value pairs with strings as values.
affects: >=1.0.0
deprecatedThe library has not been updated frequently; consider if you need active maintenance.
fix
If missing features, open an issue or contribute PR, or switch to knex.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'mysql-bricks'
Forgetting to install the package or using wrong import path.
fix
Run 'npm install mysql-bricks' and use 'import sql from "mysql-bricks"'.
TypeError: sql.insert is not a function
Importing mysql-bricks incorrectly, e.g., destructuring named exports.
fix
Use default import: 'import sql from "mysql-bricks"'.
sql-bricks is not defined
Accidentally using mysql-bricks without importing sql-bricks separately (not needed).
fix
The 'sql' object from mysql-bricks includes all sql-bricks functions; no separate import needed.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
sql-bricksrequiredCore dependency; mysql-bricks extends the sql-bricks API.
Agent activity
13 hits · last 30 days
node
12
Amazon
1
Resources
mysql-bricks — npm install mysql-bricks · libregistry