taladb
v0.6.0
Published
Local-first document and vector database for React, React Native, and Node.js
Maintainers
Readme
taladb
Local-first document database for React, React Native, and Node.js — powered by a Rust/WASM core with zero GC pauses.
What is TalaDB?
TalaDB gives you a MongoDB-style document API that runs entirely on-device — in the browser via WASM + OPFS, in React Native via JSI, and in Node.js via a native module. No cloud, no sync server, no garbage-collection pauses.
import { openDB } from 'taladb';
const db = await openDB('myapp.db');
const users = db.collection('users');
await users.createIndex('email');
const id = await users.insert({ name: 'Alice', email: '[email protected]', age: 30 });
const alice = await users.findOne({ email: '[email protected]' });
const adults = await users.find({ age: { $gte: 18 } });
await users.updateOne({ email: '[email protected]' }, { $inc: { age: 1 } });
await users.deleteOne({ email: '[email protected]' });
await db.close();Installation
# npm
npm install taladb
# pnpm
pnpm add taladb
# yarn
yarn add taladbThe package automatically loads the right backend for your platform:
| Platform | Backend |
|----------|---------|
| Browser | @taladb/web (WASM + OPFS) |
| Node.js | @taladb/node (napi-rs native module) |
| React Native | @taladb/react-native (JSI TurboModule) |
Install the appropriate platform package as well:
# Browser
pnpm add taladb @taladb/web
# Node.js
pnpm add taladb @taladb/node
# React Native
pnpm add taladb @taladb/react-nativeAPI
Database
const db = await openDB(name?: string): Promise<TalaDB>
db.collection<T>(name: string): Collection<T>
db.close(): Promise<void>Collection
// Write
col.insert(doc): Promise<string> // returns ULID id
col.insertMany(docs): Promise<string[]>
col.updateOne(filter, update): Promise<boolean>
col.updateMany(filter, update): Promise<number>
col.deleteOne(filter): Promise<boolean>
col.deleteMany(filter): Promise<number>
// Read
col.find(filter?): Promise<T[]>
col.findOne(filter): Promise<T | null>
col.count(filter?): Promise<number>
// Indexes
col.createIndex(field): Promise<void> // idempotent
col.dropIndex(field): Promise<void>Filters
{ field: value } // equality
{ field: { $eq, $ne, $gt, $gte, $lt, $lte } } // comparisons
{ field: { $in: [...], $nin: [...] } } // set membership
{ field: { $exists: true | false } } // field presence
{ $and: [...filters] }
{ $or: [...filters] }
{ $not: filter }Updates
{ $set: { field: value } } // set or replace
{ $unset: { field: true } } // remove field
{ $inc: { field: number } } // increment / decrement
{ $push: { field: value } } // append to array
{ $pull: { field: value } } // remove from arrayMigrations
Run schema migrations at open time — each migration runs exactly once, in version order:
import { runMigrations } from 'taladb';
await runMigrations(db, [
{
fromVersion: 0,
toVersion: 1,
description: 'add default role',
async up(col) {
await col('users').updateMany({}, { $set: { role: 'viewer' } });
},
},
]);Full Documentation
https://thinkgrid-labs.github.io/taladb
License
MIT © ThinkGrid Labs
