Skip to content

13angs/dotnet-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dotnet mongo

Usage:

  • Install the package
dotnet add package 13angs.Dotnet.Mongo --version 0.0.1
  • Register the config into DI container
MongodbConfig mongodbConfig = Configuration.GetMongodbConfig();
builder.Services.AddSingleton(mongodbConfig);
  • Use the service
IMongoCollection<Blog?> _blog = MongodbCollectionService.GetCollection<Blog?>(Configuration);
  • update the appsetting.json
{
    "MongodbConfig": {
        "ConnectionString": "mongodb://root:P4ssw0rd@mongo-db:27017/",
        "DatabaseName": "blog_db",
        "CollectionName": "blogs"
    }
}
  • run the Mongodb server
cd Sample && docker compose up -d

Releases

No releases published

Packages

 
 
 

Languages