Registry / database / bass-sql

bass-sql

JSON →
library0.0.29jsnpmunverified

SQL adapter for Bass.js, a JavaScript ODM (Object Document Mapper). Version 0.0.29 is the latest, with irregular releases. It provides a familiar ODM interface for SQL databases, supporting SQLite, PostgreSQL, MySQL, and MSSQL via a pluggable client. Unlike full ORMs like Sequelize or TypeORM, bass-sql keeps the ODM pattern minimal and schema-less, delegating query building to Bass.js and database connectivity to external npm packages such as sql.js, pg, mysql2, and tedious.

npm install bass-sql
INSTALL
IMPORT
SIG · BASS-SQL
B
bass-sql
databasejavascriptv0.0.29
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.

default (the adapter)
import adapter from 'bass-sql'
import { adapter } from 'bass-sql'
The default export is the adapter factory function.
bass
import bass from 'bass'
import bass from 'bass-sql'
bass is a separate package.
Model
import { Model } from 'bass'
const { Model } = require('bass-sql')
Model class is from bass, not bass-sql.

Sets up a Bass.js ODM with an SQLite backend using bass-sql, defines a model, creates a record, and queries all records.

import bass from 'bass'; import adapter from 'bass-sql'; import sqlite from 'sql.js'; // Initialize Bass.js with SQL adapter const orm = bass({ local: adapter(sqlite) }); // Define a model const User = orm.model('users', { name: String, age: Number }); async function main() { await User.create({ name: 'John', age: 30 }); const users = await User.find(); console.log(users); } main().catch(console.error);
Debug
Known issues
gotchabass-sql does not perform migrations; schema must be created manually or via other tools.
fix
Use separate migration tools like knex or typeorm migrations.
affects: >=0.0.0
deprecatedSome older API patterns may be deprecated; check Bass.js changelog for compatibility.
fix
Refer to Bass.js update notes.
affects: >=0.0.20
gotchaSQLite driver (sql.js) is included by default; if using another database, you must install the corresponding driver package.
fix
npm install pg for PostgreSQL, mysql2 for MySQL, tedious for MSSQL.
affects: >=0.0.0
gotchabass-sql may have issues with complex joins or raw SQL; it is designed for simple ODM patterns.
fix
Consider using a full ORM like Sequelize for complex SQL operations.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'sql.js'
SQLite driver is missing.
fix
npm install sql.js
TypeError: adapter is not a function
Importing incorrectly; bass-sql default export is a function that expects a driver.
fix
Use import adapter from 'bass-sql'; then adapter(driver).
Error: Dialect 'postgres' not supported
PostgreSQL driver (pg) not installed.
fix
npm install pg
Upgrade
Version history
0.0.29latest on npm
Audit
Dependencies
bassrequiredCore ODM library; bass-sql is an adapter for Bass.js models
sql.jsoptionalDefault SQLite client if no other driver specified
pgoptionalPostgreSQL client; must be installed when using postgres dialect
mysql2optionalMySQL/MariaDB client; required for mysql dialect
tediousoptionalMSSQL client; required for mssql dialect
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources