Registry / database / thorin-store-sql

thorin-store-sql

JSON →
library2.3.40jsnpmunverified

Database store plugin for the Thorin.js framework, providing SQL database connectivity and query building for MySQL, PostgreSQL, SQLite, and MariaDB. Current stable version is 2.3.40 with monthly releases. Tightly coupled to Thorin.js's event-driven architecture; not usable standalone. Supports connection pooling, migrations, and model-based CRUD operations.

npm install thorin-store-sql
INSTALL
IMPORT
SIG · THORIN-STORE-SQL
T
thorin-store-sql
databasejavascriptv2.3.40
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.

thorin
import thorin from 'thorin'
const thorin = require('thorin')
Thorin.js uses ESM modules; CommonJS require may fail in Node <16.
store
thorin.store('sql', { ... })
thorin.use('sql-store')
Store registration is done via thorin.store(), not thorin.use().
Model
thorin.model('User', { ... })
new Model(...)
Models are defined via thorin.model(), not instantiated directly.

Shows setup of SQL store with MySQL, model definition, and async CRUD operation.

import thorin from 'thorin'; thorin.store('sql', { adapter: 'mysql', host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test', pool: { min: 2, max: 10 } }); const User = thorin.model('User', { fields: { id: { type: 'number', primary: true }, name: { type: 'string' }, email: { type: 'string', unique: true } }, table: 'users' }); async function main() { await thorin.waitFor('store:sql'); const user = await User.create({ name: 'Alice', email: 'alice@example.com' }); console.log(user); await thorin.disconnect(); } main().catch(console.error);
Debug
Known issues
breakingThorin.js v2 requires Node >=14 and uses ESM only. CommonJS require will not work.
fix
Use import syntax and update Node to >=14.
affects: >=2.0.0
deprecatedThorin v1 style thorin.use('sql-store') is deprecated in v2.
fix
Use thorin.store('sql', {...}) instead.
affects: >=2.0.0
gotchaModel definitions must include a primary key field; otherwise, some operations may fail silently.
fix
Always define a primary key in model fields.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql2'
MySQL adapter used without installing the driver package.
fix
Run: npm install mysql2
TypeError: thorin.store is not a function
Thorin.js not properly imported or loaded before calling store.
fix
Ensure thorin is imported from 'thorin' (ESM) and that Thorin is initialized.
Error: Connection refused to host 'localhost'
Database server not running or connection config incorrect.
fix
Start database service and verify DB_HOST, DB_PORT settings.
Upgrade
Version history
2.3.40latest on npm
Audit
Dependencies
thorinrequiredCore framework dependency; store cannot be used without Thorin.js
mysql2optionalMySQL/MariaDB driver
pgoptionalPostgreSQL driver
sqlite3optionalSQLite driver
Agent activity
18 hits · last 30 days
node
14
Meta
2
Amazon
1
OpenAI (training)
1
Resources
thorin-store-sql — npm install thorin-store-sql · libregistry