0 votes

UmbracoMongoDbClient

Setup procedure

The appsettings.json file should be given a connection string to your MongoDB databases

{
	"MongoDbCredentials": {
	    "CertificateFilePathWithName": "<optional Certificate file path with name [pfx file]>",
	    "CertificatePassword": "<optional Certificate password>",
	    "ConnectionString": "<mandatory> mongodb+srv://cluster0.fyu.mongodb.net/?authSource=%24external&authMechanism=MONGODB-X509&retryWrites=true&w=majority"
	  }
}

Sample code

var database = MongoDBClientConnection.GetDatabase("YouDatabaseName");
var collection = database.GetCollection<T>("YourCollectionName"); // of type T

Setup procedure

The appsettings.json file should be given a connection string to your MongoDB databases, here is a sample configuration snippet :

{
	"MongoDbCredentials": {
	    "CertificateFilePathWithName": "<optional Certificate file path with name [pfx file]>",
	    "CertificatePassword": "<optional Certificate password>",
	    "ConnectionString": "<mandatory> mongodb+srv://cluster0.fyu.mongodb.net/?authSource=%24external&authMechanism=MONGODB-X509&retryWrites=true&w=majority"
	  }
}

Sample code

var database = MongoDBClientConnection.GetDatabase("YouDatabaseName");
var collection = database.GetCollection<T>("YourCollectionName"); // of type T

NuGet install instructions for Umbraco 9+

dotnet add package UmbracoMongoDbClient

Package owner

Prashansa

Prashansa

Prashansa has 74 karma points

Package Information

  • Package owner: Prashansa
  • Created: 30/10/2022
  • Current version 7.0.0
  • License MIT
  • Downloads on Our: 0
  • Downloads on NuGet: 12.9K
  • Total downloads : 12.9K

External resources