Registry / database / webiny-sql-table-mysql

webiny-sql-table-mysql

JSON →
library1.9.0jsnpmunverified

A lightweight SQL query builder for MySQL, designed for the Webiny framework. Current stable version is 1.9.0. It provides a simple, table-oriented API for building and executing SQL queries. The package has a peer dependency on serverless-mysql which handles the actual MySQL connection, making it suitable for serverless environments like AWS Lambda. It supports basic CRUD operations with automatic type handling and parameterized queries. Release cadence is low; updates are infrequent and tied to Webiny-js releases.

npm install webiny-sql-table-mysql
INSTALL
IMPORT
SIG · WEBINY-SQL-TABLE-M
W
webiny-sql-table-mysql
databasejavascriptv1.9.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.

createSqlTableMySQL
import { createSqlTableMySQL } from 'webiny-sql-table-mysql'
const createSqlTableMySQL = require('webiny-sql-table-mysql')
The package is ESM-only; CommonJS require is not supported.
default
import SqlTable from 'webiny-sql-table-mysql'
Default export is the same as named export createSqlTableMySQL. Prefer named import for clarity.
types
import { Table, Query, Where } from 'webiny-sql-table-mysql'
TypeScript types are exported for Table, Query, and Where interfaces. These are not runtime values.

Creates a table object with schema definition, inserts a record, and queries using a where clause.

import { createSqlTableMySQL } from 'webiny-sql-table-mysql'; import mysql from 'serverless-mysql'; const db = mysql({ config: { host: process.env.DB_HOST ?? 'localhost', database: process.env.DB_NAME ?? 'test', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '' } }); const table = createSqlTableMySQL({ table: 'users', primaryKey: 'id', fields: { id: { type: 'integer' }, name: { type: 'string' }, email: { type: 'string' } } }); async function run() { const result = await table.insert(db, { name: 'John', email: 'john@example.com' }); console.log('Inserted:', result); const users = await table.find(db, { where: { name: { $eq: 'John' } } }); console.log('Found:', users); await db.end(); } run().catch(console.error);
Debug
Known issues
breakingPackage is ESM-only since v1.0.0. Using require() will throw an error.
fix
Use import syntax. If CommonJS required, wrap in dynamic import: import('webiny-sql-table-mysql').then(m => ...)
affects: >=1.0.0
deprecatedThe $eq operator in where clause is deprecated in favor of direct equality (e.g., { name: 'John' }).
fix
Replace { $eq: value } with value directly in the where object.
affects: >=1.5.0
gotchaThe package does not handle connection pooling; serverless-mysql manages connections. Ensure db.end() is called after each invocation in serverless environments.
fix
Always call await db.end() after query operations to close the connection.
affects: *
gotchaField types are not enforced; the type option in fields is for documentation only. Incorrect types can cause runtime errors.
fix
Ensure values passed to insert/update match the MySQL column types. Use explicit type conversions if needed.
affects: *
Errors
Common errors & fixes
Cannot find module 'webiny-sql-table-mysql' when using require()
Package is ESM-only and does not support CommonJS require.
fix
Use import syntax or dynamic import: import('webiny-sql-table-mysql')
TypeError: createSqlTableMySQL is not a function
Using require() on an ESM package that exports named exports.
fix
Switch to import { createSqlTableMySQL } from 'webiny-sql-table-mysql'
Upgrade
Version history
1.9.0latest on npm
Audit
Dependencies
serverless-mysqlrequiredProvides the MySQL connection and query execution. Must be installed separately.
Agent activity
27 hits · last 30 days
node
22
Meta
1
OpenAI (training)
1
Resources
webiny-sql-table-mysql — npm install webiny-sql-table-mysql · libregistry