Skip to content

Commit c58caf6

Browse files
authored
fix: support for cosmodb (#24)
1 parent cbe750b commit c58caf6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

backend/Tim.Backend/Providers/Database/MongoDbClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ private async Task CreateCollectionAsync(string collectionName)
8585
private async Task CreateKustoExpireIndexKustoQueryRun(string collectionName)
8686
{
8787
var builder = Builders<KustoQueryRun>.IndexKeys;
88+
var keys = m_configs.WithCosmosDb ? builder.Ascending("_ts") : builder.Ascending(x => x.ExecuteDateTimeUtc);
8889
var indexModel = new CreateIndexModel<KustoQueryRun>(
89-
builder.Ascending(x => x.ExecuteDateTimeUtc),
90+
keys,
9091
new CreateIndexOptions
9192
{
9293
ExpireAfter = TimeSpan.FromDays(1),

backend/Tim.Backend/Startup/Config/MongoConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public MongoConfiguration()
3333
[Required]
3434
public string DatabaseName { get; set; } = Environment.GetEnvironmentVariable("MONGO_DATABASE_NAME");
3535

36+
/// <summary>
37+
/// Gets or sets a value indicating whether cosmosdb is being used.
38+
/// </summary>
39+
public bool WithCosmosDb { get; set; } = Environment.GetEnvironmentVariable("MONGO_WITH_COSMOSDB") == "true";
40+
3641
/// <summary>
3742
/// Ensures that all required values are populated.
3843
/// </summary>

0 commit comments

Comments
 (0)