Stage 1 of migrating to MongoDb - fully added mongodb

This commit is contained in:
2024-12-15 17:01:48 +03:30
parent e0cdcf1198
commit fbe0d500d9
5 changed files with 13 additions and 13 deletions

View File

@@ -14,7 +14,7 @@ namespace mstdnCats.Services
try
{
// Initialize Backup DB
var store = new DataStore($"{_dbname + "_BK"}.json", minifyJson: true);
var store = new DataStore($"./data/{_dbname + "_BK"}.json", minifyJson: true);
collection = store.GetCollection<Post>();
}
catch
@@ -26,7 +26,7 @@ namespace mstdnCats.Services
return Task.FromResult(collection);
}
public static Task<IMongoDatabase> SetupDb(string mongoDbConnectionString, string dbName)
public static Task<IMongoCollection<Post>> SetupDb(string mongoDbConnectionString, string dbName)
{
if (mongoDbConnectionString == null)
{
@@ -36,7 +36,7 @@ namespace mstdnCats.Services
try
{
var client = new MongoClient(mongoDbConnectionString);
var database = client.GetDatabase(dbName);
var database = client.GetDatabase(dbName).GetCollection<Post>("posts");
return Task.FromResult(database);
}
catch (Exception ex)