Skip to main content
Version: v1.31.0


The mongodbRetriever will use the mongoDB database to get your flags.


err := ffclient.Init(ffclient.Config{
PollingInterval: 3 * time.Second,
Retriever: &mongodbretriever.Retriever{
Collection: "featureFlags",
Database: "appConfig",
URI: "mongodb://root:example@",
defer ffclient.Close()

Expected format

If you use MongoDB to store your flags, you need a specific format to store your flags.

We expect the flag to be stored in JSON format as defined in the flag format, but you should also add a new field called flag containing the name of the flag.

The retriever will read all the flags from the collection.


"flag": "new-admin-access",
"variations": {
"default_var": false,
"false_var": false,
"true_var": true
"defaultRule": {
"percentage": {
"false_var": 70,
"true_var": 30

Configuration fields

To configure your mongodb retriever:

CollectionName of the collection where your flags are stored
DatabaseName of the mongo database where the collection is located.
URIConnection URI of your mongoDB instance.

Get the latest GO Feature Flag updates