Skip to main content

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:

PackageDescription
@oimdb/coreReactive collections, indexes, event queue, selectors
@oimdb/reactReact hooks and context provider
@oimdb/redux-adapterRedux reducers backed by OIMDB, two-way sync
@oimdb/asyncAsync collections and indexes
@oimdb/persistStorage-agnostic persistence engine for collections, objects, indexes; onHydrate/byPk hydration-merge
@oimdb/persist-memoryPersist backend: in-memory Map (tests, SSR)
@oimdb/persist-localstoragePersist backend: localStorage
@oimdb/persist-idbPersist backend: IndexedDB
@oimdb/persist-jsonPersist backend: JSON dump for SSR dehydrate/hydrate
@oimdb/persist-async-kvPersist backend: async key-value — React Native AsyncStorage, Cordova
@oimdb/snapshot-managerTrack 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