createMongoStorage
function createMongoStorage(options): MongoAuditStorage;Defined in: src/storage/mongodb.ts:173
Create a MongoDB-backed MongoAuditStorage. Connection is lazy: the client is created/connected on the first storage operation and reused thereafter, guarded by a single connection promise so concurrent calls connect once. Event indexes are created on the first event operation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
MongoStorageOptions |
Returns
Section titled “Returns”Example
Section titled “Example”import { createMongoStorage } from "@xtandard/audit/storage/mongodb";
const storage = createMongoStorage({ url: process.env.MONGODB_URL ?? "mongodb://localhost:27017", dbName: "myapp",});
// Disconnect when the process exits:// process.on("SIGTERM", () => storage.close());