Skip to content

createMongoStorage

function createMongoStorage(options): MongoFlagsStorage;

Defined in: storage/mongodb.ts:60

Create a MongoDB-backed MongoFlagsStorage. Connection is lazy: the client is created/connected on the first storage operation and reused thereafter.

Parameter Type
options MongoStorageOptions

MongoFlagsStorage

import { createMongoStorage } from "@xtandard/flags/storage/mongodb";
const storage = createMongoStorage({
url: process.env.MONGODB_URL ?? "mongodb://localhost:27017",
dbName: "myapp",
collectionName: "flags_kv",
});
// Disconnect when the process exits:
// process.on("SIGTERM", () => storage.close());