MongoDB.Driver C# auto expire documents


MongoDB.Driver C# auto expire documents



I am inserting documents into a collection and have a field called ExpireWhen. I would like to automatically remove those documents when the date has expired. I tried looking around but was not able to find information using the mongo db driver for c# version 2.6.1



I tried the following but it doesn't seem to do anything.


this.CacheItemRecords().Indexes.CreateOneAsync(
Builders<CacheItemRecordEntry>.IndexKeys.Ascending(_ =>_.ExpireWhen),
new CreateIndexOptions { ExpireAfter = new TimeSpan(0, 0, 0) }
);









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Possible Unhandled Promise Rejection (id: 0): ReferenceError: user is not defined ReferenceError: user is not defined