BlinkDB
raw JSON → 0.14.0 verified Sat Apr 25 auth: no javascript
BlinkDB is an in-memory JavaScript database optimized for large-scale data on the client side. Current stable version is 0.14.0, released with a monthly cadence. It provides indexed queries, filtering, sorting, and pagination, serving as a high-performance alternative to Redux or MobX for SPAs. Key differentiator: database-like querying with an API inspired by Prisma, supporting both relational and non-relational data. Not yet production-ready (pre-1.0.0). Ships TypeScript types.
Common errors
error TypeError: (0 , blinkdb_1.createTable) is not a function ↓
cause Using named import from default export; likely import createTable from 'blinkdb' instead of named import.
fix
Use import { createTable } from 'blinkdb' (named import).
error Cannot find module 'blinkdb' ↓
cause Package not installed or module system mismatch.
fix
Run 'npm install blinkdb' and ensure project is configured for ESM (use --type module in package.json or .mjs extension).
error Error: BlinkDB is not a constructor ↓
cause Importing class as default instead of named.
fix
Use import { BlinkDB } from 'blinkdb'.
error Property 'in' does not exist on type 'WhereClause' ↓
cause Using the 'in' operator is only supported in TypeScript with specific index types.
fix
Ensure table is created with an index on the 'name' field: createTable<User>(db, 'users')({ primary: 'id', indexes: ['name'] })
Warnings
breaking Breaking change in v0.13.0: createTable no longer returns Table directly, but a function that must be called. ↓
fix Use createTable<T>(db, name)() with double parentheses or pass options as second argument.
deprecated Deprecated in v0.13.0: The 'update' function is deprecated in favor of 'upsert'. ↓
fix Replace update with upsert to update or insert a record.
gotcha TypeScript: The 'Table' type is not exported as a value; attempting to import { Table } at runtime will be undefined. ↓
fix Use import type { Table } from 'blinkdb' for type-only imports.
gotcha All query functions (many, first, insert, etc.) are async and return Promises. ↓
fix Always await query results or use .then().
deprecated Deprecated in v0.11.0: 'query' function replaced by 'many' for consistency. ↓
fix Use many instead of query.
Install
npm install blinkdb yarn add blinkdb pnpm add blinkdb Imports
- many wrong
const { many } = require('blinkdb')correctimport { many } from 'blinkdb' - first wrong
import first from 'blinkdb'correctimport { first } from 'blinkdb' - createTable wrong
import { table } from 'blinkdb'correctimport { createTable } from 'blinkdb' - BlinkDB wrong
import BlinkDB from 'blinkdb'correctimport { BlinkDB } from 'blinkdb' - type Table wrong
import { Table } from 'blinkdb'correctimport type { Table } from 'blinkdb'
Quickstart
import { createTable, many, insert, BlinkDB } from 'blinkdb';
const db = new BlinkDB();
const usersTable = createTable<User>(db, 'users')();
interface User {
id: number;
name: string;
age: number;
}
await insert(usersTable, {
id: 1, name: 'Alice', age: 30,
id: 2, name: 'Bob', age: 25,
id: 3, name: 'Charlie', age: 35
});
const result = await many(usersTable, {
where: {
age: { gt: 24 }
},
sort: { age: 'asc' },
limit: 10
});
console.log(result);