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);
Errors
Common errors & fixes
Error: Cannot find module 'mysql2'
MySQL adapter used without installing the driver package.
fixRun: npm install mysql2
TypeError: thorin.store is not a function
Thorin.js not properly imported or loaded before calling store.
fixEnsure 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.
fixStart database service and verify DB_HOST, DB_PORT settings.
Audit
Dependencies
thorinrequiredCore framework dependency; store cannot be used without Thorin.js
mysql2optionalMySQL/MariaDB driver
pgoptionalPostgreSQL driver
sqlite3optionalSQLite driver