OIMDB
A high-performance, event-driven in-memory database designed specifically for frontend applications. OIMDB provides reactive collections, intelligent indexing, and configurable event processing for building fast, predictable state management solutions.
Packages
OIMDB is organized as a monorepo with separate npm packages:
| Package | Description |
|---|---|
@oimdb/core | Reactive collections, indexes, event queue, selectors |
@oimdb/react | React hooks and context provider |
@oimdb/redux-adapter | Redux reducers backed by OIMDB, two-way sync |
@oimdb/async | Async collections and indexes |
@oimdb/persist | Storage-agnostic persistence engine for collections, objects, indexes; onHydrate/byPk hydration-merge |
@oimdb/persist-memory | Persist backend: in-memory Map (tests, SSR) |
@oimdb/persist-localstorage | Persist backend: localStorage |
@oimdb/persist-idb | Persist backend: IndexedDB |
@oimdb/persist-json | Persist backend: JSON dump for SSR dehydrate/hydrate |
@oimdb/persist-async-kv | Persist backend: async key-value — React Native AsyncStorage, Cordova |
@oimdb/snapshot-manager | Track and snapshot cross-collection changes |
Key Benefits
- Performance first — Map-based storage with O(1) lookups
- Reactive architecture — Key-scoped subscriptions with intelligent coalescing
- Type safety — Full TypeScript support with advanced generics
- Configurable — Multiple scheduler options for different use cases
- Modular — Use only what you need, extend what you want
Quick Example
import {
createOIMCollectionKit,
OIMEventQueue,
OIMEventQueueSchedulerFactory,
} from '@oimdb/core';
interface User {
id: string;
name: string;
email: string;
teamId: string;
}
const queue = new OIMEventQueue({
scheduler: OIMEventQueueSchedulerFactory.createMicrotask(),
});
const users = createOIMCollectionKit<User, string>(queue, {
selectPk: (user) => user.id,
});
const usersByTeam = users.indexFactory.derivedSetIndex((user) => user.teamId);
const teamUsers = users.select.entitiesBySetIndexKey(usersByTeam, 'team1');
users.collection.updateEventEmitter.subscribeOnKey('user1', () => {
console.log('User1 updated!');
});
const userSlot = users.collection.upsertOne({
id: 'user1',
name: 'John',
email: 'john@example.com',
teamId: 'team1',
});
const updatedUserSlot = users.collection.upsertOne({
id: 'user1',
name: 'John Doe',
email: 'john@example.com',
teamId: 'team1',
});
console.log(userSlot === updatedUserSlot); // true
teamUsers.watch((value) => console.log(value));
// Only one notification fires due to intelligent coalescing
Next Steps
- Installation — install the packages you need
- Quick Start — build your first reactive schema
- Core Model — collections, slots, indexes, and selectors
- Indexes and Selectors — derived indexes, manual indexes, and selector DX
- Performance Guide — benchmarks and optimization strategies