UNPKG

@furystack/mongodb-store

Version:

MongoDB Store implementation for FuryStack

39 lines (29 loc) 1.06 kB
# @furystack/mongodb-store MongoDB physical store implementation for FuryStack. ## Installation ```bash npm install @furystack/mongodb-store # or yarn add @furystack/mongodb-store ``` ## Initialization ```ts import { Injector } from '@furystack/inject' import { StoreManager } from '@furystack/core' import { useMongoDb } from '@furystack/mongodb-store' export class TestEntry { declare _id: string declare value: string } const myInjector = new Injector() useMongoDb({ injector: myInjector, model: TestEntry, primaryKey: '_id', url: 'mongodb://localhost:27017', db: 'test', collection: 'TestEntries', }) const myMongoStore = myInjector.getInstance(StoreManager).getStoreFor(TestEntry, '_id') ``` > **Tip:** For application-level data access, wrap the physical store with a Repository DataSet using `getRepository(injector).createDataSet(Model, 'primaryKey')` and then use `getDataSetFor(injector, Model, 'primaryKey')` from `@furystack/repository`. This ensures authorization, hooks, and entity sync events are properly triggered.