Registry / database / think-model-sqlite

think-model-sqlite

JSON →
library1.3.2jsnpmunverified

SQLite adapter for the ThinkJS 3.x ORM model layer. Version 1.3.2 is the latest stable release. This package allows ThinkJS models to connect to SQLite databases via the sqlite3 driver. It follows the same adapter interface as think-model-mysql, making it easy to switch databases. The adapter supports basic CRUD operations, transactions, and query building. It is still actively maintained alongside ThinkJS v3.

npm install think-model-sqlite
INSTALL
IMPORT
SIG · THINK-MODEL-SQLITE
T
think-model-sqlite
databasejavascriptv1.3.2
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
✓ import SQLiteAdapter from 'think-model-sqlite'
✗ const SQLiteAdapter = require('think-model-sqlite')
The package exports a single class as default, not a module. Use default import in TypeScript.
thinkModelSqlite
✓ import thinkModelSqlite from 'think-model-sqlite'
✗ import { thinkModelSqlite } from 'think-model-sqlite'
No named exports exist; only default.
require()
✓ const SQLiteAdapter = require('think-model-sqlite').default
✗ const SQLiteAdapter = require('think-model-sqlite')
In CommonJS, require returns the module object with a default property. Use .default to get the class.

Shows how to configure ThinkJS 3.x to use SQLite adapter for models.

import SQLiteAdapter from 'think-model-sqlite'; import Model from 'think-model'; // Configure ThinkJS to use SQLite adapter // In your model config (e.g., src/config/model.js): export default { type: 'sqlite', adapter: { sqlite: { handle: new SQLiteAdapter(), config: { path: './data.db', // Path to SQLite database file options: {} } } } }; // Then use models as usual (assuming you have a model file): // model/User.js export default class extends Model { constructor() { super(); this.tableName = 'user'; } } // In a controller: import UserModel from './model/User'; const user = await new UserModel().where({ id: 1 }).find(); console.log(user);
Debug
Known issues
gotchaEnsure the sqlite3 native module is installed and compatible with your Node version.
fix
Run 'npm install sqlite3' and check Node version compatibility.
affects: >=1.0
deprecatedThe package still uses callbacks internally; Promises are supported via wrapper.
fix
Avoid mixing callbacks and async/await in the same call chain.
affects: >=1.3
gotchaThe 'path' config must be absolute or relative to process.cwd(); relative paths are resolved at runtime.
fix
Use an absolute path or ensure process.cwd() is correct.
affects: >=1.0
gotchaTransactions are not fully documented; use think-model's transaction method cautiously.
fix
Refer to think-model documentation for transaction usage.
affects: >=1.0
breakingVersion 1.x requires think-model >=3.0; breaking changes from think-model v2.
fix
Upgrade think-model to v3 and follow migration guide.
affects: >=1.0
Errors
Common errors & fixes
Error: Cannot find module 'sqlite3'
sqlite3 native module not installed.
fix
Run 'npm install sqlite3' in your project root.
TypeError: thinkModelSqlite is not a constructor
Using named import instead of default import.
fix
Use 'import thinkModelSqlite from 'think-model-sqlite'' instead of '{ thinkModelSqlite }'.
Error: SQLITE_NOTADB - file is not a database
The SQLite file path is invalid or the file is corrupt.
fix
Check the 'path' config and ensure it points to a valid SQLite file.
Upgrade
Version history
1.3.2latest on npm
Audit
Dependencies
think-modelrequiredProvides the base model class and adapter interface
sqlite3requiredNative SQLite driver
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
think-model-sqlite — npm install think-model-sqlite · libregistry