@nwire/store-mongo
v0.7.1
Published
Nwire — MongoDB adapters for ActorStore + ProjectionStore. (actorName, key, tenant) compound PK; fireAtList denormalized for indexable timer-scheduler queries; ensureIndexes() idempotent.
Downloads
220
Readme
@nwire/store-mongo
MongoDB-backed
ActorStore+ProjectionStore— the canonical production store.
What it does
Persists actor state and projection rows to MongoDB. Tenant-partitioned. Includes idempotent ensureIndexes() ({actorName, tenant}, {actorName, fireAtList} for the timer scheduler, {projectionName, tenant} for read paths). Tested via mongodb-memory-server so suites run without Docker.
Install
pnpm add @nwire/store-mongo mongodbQuick start
import { MongoClient } from "mongodb";
import { MongoActorStore, MongoProjectionStore } from "@nwire/store-mongo";
import { createApp } from "@nwire/forge";
const client = await MongoClient.connect(process.env.MONGODB_URL!);
const db = client.db("learnflow");
const actorStore = new MongoActorStore(db.collection("actors"));
const projectionStore = new MongoProjectionStore(db.collection("projections"));
await actorStore.ensureIndexes();
await projectionStore.ensureIndexes();
const app = createApp("learnflow", { modules, actorStore, projectionStore });API surface
MongoActorStore(collection)— implementsActorStore;.ensureIndexes().MongoProjectionStore(collection)— implementsProjectionStore;.ensureIndexes().
When to use
Production workloads with stateful actors and read-model projections.
Within nwire-app
For developers using this package as part of the Nwire stack — register it via app.use(...) or it auto-wires when you compose createApp({ modules }).
import { createApp } from "@nwire/forge";
const app = createApp({
/* ...config... */
});
// Adapter/plugin wiring happens here when applicable.