Skip to content

@xtandard/audit/storage/mongodb

MongoDB storage: createMongoStorage() over the mongodb driver — a KV collection of { _id: key, value } documents for control data plus a native, indexed events collection (the EventLogStorage capability).

import { … } from "@xtandard/audit/storage/mongodb";
Name Summary
createMongoStorage 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.
mongoEventFilter Compile a NormalizedQuery to a Mongo filter that agrees exactly with matchesQuery (plus the keyset position when the query has one).
Name Summary
MongoAuditStorage An EventLogStorage backed by MongoDB, plus a close() method that disconnects the client — but only the one this adapter created. A client you passed in is left for you to manage.
MongoStorageOptions Options for createMongoStorage: a client or a url, the database (dbName, default "xtandard_audit") and the KV collection (collectionName, default "audit_kv").
Name Summary
EventDoc An event document: the event plus its denormalized search text.