Registry / storage / mtkruto-storage-sqlite

mtkruto-storage-sqlite

JSON →
library0.0.2jsnpmunverified

SQLite storage adapter for MTKruto (MTProto/Kruto Telegram client). Current stable version 0.0.2, actively maintained. Key differentiator: driver-agnostic (works with both better-sqlite3 and bun:sqlite), synchronous API for zero async overhead, supports branching, range queries, atomic incr, and stores BigInt/Uint8Array. Requires Node >=18 and @mtkruto/node >=0.141.0.

npm install mtkruto-storage-sqlite
INSTALL
IMPORT
SIG · MTKRUTO-STORAGE-SQ
M
mtkruto-storage-sqlite
storagejavascriptv0.0.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.

StorageSqlite
import { StorageSqlite } from 'mtkruto-storage-sqlite'
const StorageSqlite = require('mtkruto-storage-sqlite')
ESM-only package; no CommonJS support.
SqliteDatabase
import type { SqliteDatabase } from 'mtkruto-storage-sqlite'
import { SqliteDatabase } from 'mtkruto-storage-sqlite'
SqliteDatabase is only a TypeScript interface; do not import as a value.
Database (from better-sqlite3)
import Database from 'better-sqlite3'; const db = new Database('session.db'); const storage = new StorageSqlite(db)
import { Database } from 'better-sqlite3'
better-sqlite3 uses default export, not named.

Shows how to create a SQLite storage adapter using better-sqlite3 and pass it to MTKruto client.

import Database from 'better-sqlite3'; import { StorageSqlite } from 'mtkruto-storage-sqlite'; import { Client } from '@mtkruto/node'; const db = new Database('session.db'); const storage = new StorageSqlite(db); const client = new Client(storage, Number(process.env.API_ID ?? ''), process.env.API_HASH ?? ''); await client.connect(); console.log('Connected to Telegram');
Debug
Known issues
gotchaPackage is ESM-only; do not use require().
fix
Use 'import { StorageSqlite } from 'mtkruto-storage-sqlite' and ensure your project is ESM (e.g., type: module in package.json).
affects: >=0.0.0
gotchaSqliteDatabase is an interface, not a class. Attempting to instantiate it will cause a runtime error.
fix
Import only as type: import type { SqliteDatabase } from 'mtkruto-storage-sqlite'.
affects: >=0.0.0
gotchabetter-sqlite3's Database is a default export, not named.
fix
Use import Database from 'better-sqlite3' (no destructuring).
affects: >=0.0.0
gotchaThe peer dependency @mtkruto/node must be >=0.141.0, otherwise storage may not be compatible.
fix
Update @mtkruto/node to 0.141.0 or later.
affects: >=0.0.0
gotchabun:sqlite is only available when running with Bun runtime; using it in Node will fail.
fix
Use better-sqlite3 when running on Node.js.
affects: >=0.0.0
Errors
Common errors & fixes
ERR_MODULE_NOT_FOUND: Cannot find package 'mtkruto-storage-sqlite'
Package not installed or npm not configured correctly.
fix
Run 'npm install mtkruto-storage-sqlite'.
TypeError: Class constructor StorageSqlite cannot be invoked without 'new'
Trying to call StorageSqlite without new keyword.
fix
Use 'new StorageSqlite(db)'.
TypeError: db.prepare is not a function
The provided db object does not implement the SqliteDatabase interface (e.g., passed a string instead of a Database instance).
fix
Ensure you pass a Database instance from better-sqlite3 or bun:sqlite, not a path string.
Error: The 'incr' method is not supported on this database driver
Using a database driver that doesn't support atomic increment (e.g., unsupported sqlite wrapper).
fix
Use better-sqlite3 or bun:sqlite as the driver.
TypeError: Cannot read properties of undefined (reading 'prepare')
The storage was not initialized (initialize() not called), or MTKruto did not auto-initialize.
fix
Ensure client.connect() is awaited; if manual, call storage.initialize() first.
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies
@mtkruto/noderequiredPeer dependency; the storage adapter is used with MTKruto client
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
2
Resources
mtkruto-storage-sqlite — npm install mtkruto-storage-sqlite · libregistry