using FozFc.Api.Configuration;
using MongoDB.Bson;
using MongoDB.Driver;
namespace FozFc.Api.Infrastructure.Mongo;
///
/// Owns the singleton and hands out collections.
/// The Mongo driver's client/database objects are thread-safe and meant to be
/// reused for the lifetime of the application.
///
public sealed class MongoContext
{
private readonly IMongoDatabase _database;
public MongoContext(AppOptions options)
{
var client = new MongoClient(options.MongoUri);
_database = client.GetDatabase(options.MongoDatabase);
}
public IMongoCollection Collection(string name) =>
_database.GetCollection(name);
}