Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 738 Bytes

README.md

File metadata and controls

42 lines (30 loc) · 738 Bytes

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