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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
MongoStorageOptions |
Returns
Section titled “Returns”Example
Section titled “Example”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());