This is a MongoDB provider for underflag (feature flag/feature toggle)
Using npm:
npm install underflag-mongodb
Using yarn:
yarn add underflag-mongodb
Import the underflag and prepare to load data provider
import { Underflag } from "underflag";
import { MongodbDataProvider } from "underflag-mongodb";
import { MongoClient } from 'mongodb';
const client = new MongoClient(config.mongoUrl);
await client.connect();
const dataProvider = new MongodbDataProvider({ db: client.db() });
const underflag = new Underflag({ dataProvider });
if (await underflag.isOn("feature")) {
// ...
}
Attention: Do not forget of create the features collection in mongodb with the key and value fields.
Know more on underflag npm page