Toggly.FeatureManagement.Storage.MongoDB 3.2.4

dotnet add package Toggly.FeatureManagement.Storage.MongoDB --version 3.2.4
                    
NuGet\Install-Package Toggly.FeatureManagement.Storage.MongoDB -Version 3.2.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Toggly.FeatureManagement.Storage.MongoDB" Version="3.2.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Toggly.FeatureManagement.Storage.MongoDB" Version="3.2.4" />
                    
Directory.Packages.props
<PackageReference Include="Toggly.FeatureManagement.Storage.MongoDB" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Toggly.FeatureManagement.Storage.MongoDB --version 3.2.4
                    
#r "nuget: Toggly.FeatureManagement.Storage.MongoDB, 3.2.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Toggly.FeatureManagement.Storage.MongoDB@3.2.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Toggly.FeatureManagement.Storage.MongoDB&version=3.2.4
                    
Install as a Cake Addin
#tool nuget:?package=Toggly.FeatureManagement.Storage.MongoDB&version=3.2.4
                    
Install as a Cake Tool

Toggly MongoDB Snapshot Provider

MongoDB snapshot provider for Toggly Feature Management. Stores feature flag snapshots in MongoDB for high availability and horizontal scalability.

Installation

dotnet add package Toggly.FeatureManagement.Storage.MongoDB

Usage

Basic Setup

using Toggly.FeatureManagement.Storage.MongoDB.Configuration;

services.AddTogglyMongoDBSnapshotProvider(
    Configuration.GetConnectionString("MongoDB")
);

// Then configure Toggly as usual
services.AddTogglyFeatureManagement(options => {
    options.AppKey = "your-app-key";
    options.Environment = "production";
});

With Custom Settings

services.AddTogglyMongoDBSnapshotProvider(
    "mongodb://localhost:27017",
    options => {
        options.DatabaseName = "my_app";           // Default: "toggly"
        options.CollectionName = "feature_flags";  // Default: "snapshots"
        options.DocumentName = "my_features";      // Default: "toggly_features"
        options.JwkDocumentName = "my_jwks";       // Default: "toggly_jwks"
    }
);

With MongoClient Settings

var clientSettings = MongoClientSettings.FromConnectionString(connectionString);
clientSettings.ServerApi = new ServerApi(ServerApiVersion.V1);
clientSettings.MaxConnectionPoolSize = 100;

services.AddTogglyMongoDBSnapshotProvider(clientSettings, options => {
    options.DatabaseName = "toggly";
    options.CollectionName = "snapshots";
});

With Existing MongoClient

var mongoClient = new MongoClient("mongodb://localhost:27017");

services.AddTogglyMongoDBSnapshotProvider(mongoClient, options => {
    options.DatabaseName = "toggly";
});

Using Existing Registration

If you've already registered IMongoClient:

// Register MongoDB client separately
services.AddSingleton<IMongoClient>(sp =>
    new MongoClient(Configuration.GetConnectionString("MongoDB"))
);

// Then just add the snapshot provider
services.AddTogglyMongoDBSnapshotProvider();

Document Schema

The provider stores snapshots as documents in the configured collection:

{
    "_id": "toggly_features",
    "data": "{ ... serialized JSON ... }",
    "signature": "...",
    "keyId": "key-123",
    "timestamp": 1234567890,
    "updatedAt": ISODate("2024-01-15T10:30:00Z")
}
Field Type Description
_id String Document identifier (toggly_features or toggly_jwks)
data String JSON serialized snapshot data
signature String Signature for signed definitions (nullable)
keyId String Key ID for signature verification (nullable)
timestamp Int64 Unix timestamp of the snapshot
updatedAt DateTime Last update time

Configuration Options

Option Type Default Description
DatabaseName string "toggly" MongoDB database name
CollectionName string "snapshots" Collection name for snapshots
DocumentName string "toggly_features" ID for the feature snapshot document
JwkDocumentName string "toggly_jwks" ID for the JWK snapshot document

MongoDB Connection String Examples

Local Development

mongodb://localhost:27017

Replica Set

mongodb://host1:27017,host2:27017,host3:27017/?replicaSet=myReplicaSet

MongoDB Atlas

mongodb+srv://user:password@cluster.mongodb.net/?retryWrites=true&w=majority

With Authentication

mongodb://user:password@localhost:27017/admin

Index Recommendations

For optimal performance, consider creating an index on the _id field (automatic) and the updatedAt field:

db.snapshots.createIndex({ "updatedAt": -1 })

License

MIT License - see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.2.4 111 4/8/2026
3.2.3 110 3/24/2026
3.2.2 117 3/2/2026
3.2.1 104 3/1/2026
3.1.1 102 3/1/2026