{"id":46612,"library":"think-model-sqlite","title":"think-model-sqlite","description":"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.","status":"active","version":"1.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/thinkjs/think-model-sqlite","tags":["javascript","thinkjs","orm","mysql","adapter","model","typescript"],"install":[{"cmd":"npm install think-model-sqlite","lang":"bash","label":"npm"},{"cmd":"yarn add think-model-sqlite","lang":"bash","label":"yarn"},{"cmd":"pnpm add think-model-sqlite","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the base model class and adapter interface","package":"think-model","optional":false},{"reason":"Native SQLite driver","package":"sqlite3","optional":false}],"imports":[{"note":"The package exports a single class as default, not a module. Use default import in TypeScript.","wrong":"const SQLiteAdapter = require('think-model-sqlite')","symbol":"default","correct":"import SQLiteAdapter from 'think-model-sqlite'"},{"note":"No named exports exist; only default.","wrong":"import { thinkModelSqlite } from 'think-model-sqlite'","symbol":"thinkModelSqlite","correct":"import thinkModelSqlite from 'think-model-sqlite'"},{"note":"In CommonJS, require returns the module object with a default property. Use .default to get the class.","wrong":"const SQLiteAdapter = require('think-model-sqlite')","symbol":"require()","correct":"const SQLiteAdapter = require('think-model-sqlite').default"}],"quickstart":{"code":"import SQLiteAdapter from 'think-model-sqlite';\nimport Model from 'think-model';\n\n// Configure ThinkJS to use SQLite adapter\n// In your model config (e.g., src/config/model.js):\nexport default {\n  type: 'sqlite',\n  adapter: {\n    sqlite: {\n      handle: new SQLiteAdapter(),\n      config: {\n        path: './data.db',  // Path to SQLite database file\n        options: {}\n      }\n    }\n  }\n};\n\n// Then use models as usual (assuming you have a model file):\n// model/User.js\nexport default class extends Model {\n  constructor() {\n    super();\n    this.tableName = 'user';\n  }\n}\n\n// In a controller:\nimport UserModel from './model/User';\nconst user = await new UserModel().where({ id: 1 }).find();\nconsole.log(user);","lang":"typescript","description":"Shows how to configure ThinkJS 3.x to use SQLite adapter for models."},"warnings":[{"fix":"Run 'npm install sqlite3' and check Node version compatibility.","message":"Ensure the sqlite3 native module is installed and compatible with your Node version.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Avoid mixing callbacks and async/await in the same call chain.","message":"The package still uses callbacks internally; Promises are supported via wrapper.","severity":"deprecated","affected_versions":">=1.3"},{"fix":"Use an absolute path or ensure process.cwd() is correct.","message":"The 'path' config must be absolute or relative to process.cwd(); relative paths are resolved at runtime.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Refer to think-model documentation for transaction usage.","message":"Transactions are not fully documented; use think-model's transaction method cautiously.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Upgrade think-model to v3 and follow migration guide.","message":"Version 1.x requires think-model >=3.0; breaking changes from think-model v2.","severity":"breaking","affected_versions":">=1.0"}],"env_vars":null,"search_vec":"'1.3.2':16 '3':10 'activ':66 'adapt':6,40,54,75 'allow':24 'alongsid':68 'basic':56 'build':62 'connect':28 'crud':57 'databas':31,52 'driver':35 'easi':49 'follow':37 'interfac':41 'javascript':71 'latest':19 'layer':14 'maintain':67 'make':47 'model':3,13,26,45,76 'mysql':46,74 'oper':58 'orm':12,73 'packag':23 'queri':61 'releas':21 'sqlite':4,5,30 'sqlite3':34 'stabl':20 'still':65 'support':55 'switch':51 'think':2,44 'think-model-mysql':43 'think-model-sqlit':1 'thinkj':9,25,69,72 'transact':59 'typescript':77 'v3':70 'version':15 'via':32 'x':11","created_at":"2026-06-07T13:00:46.343110+00:00","updated_at":"2026-06-07T13:00:46.343110+00:00","problems":[{"fix":"Run 'npm install sqlite3' in your project root.","cause":"sqlite3 native module not installed.","error":"Error: Cannot find module 'sqlite3'"},{"fix":"Use 'import thinkModelSqlite from 'think-model-sqlite'' instead of '{ thinkModelSqlite }'.","cause":"Using named import instead of default import.","error":"TypeError: thinkModelSqlite is not a constructor"},{"fix":"Check the 'path' config and ensure it points to a valid SQLite file.","cause":"The SQLite file path is invalid or the file is corrupt.","error":"Error: SQLITE_NOTADB - file is not a database"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/thinkjs/think-model-sqlite#readme","github":"https://github.com/thinkjs/think-model-sqlite","docs":null,"changelog":null,"pypi":null,"npm":"think-model-sqlite","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}