wabbajack/Wabbajack.BuildServer/Models/NexusCacheData.cs

29 lines
818 B
C#
Raw Normal View History

2020-01-08 04:41:50 +00:00
using System;
2020-01-13 04:04:46 +00:00
using System.Threading.Tasks;
2020-01-08 04:41:50 +00:00
using MongoDB.Bson.Serialization.Attributes;
2020-01-13 04:04:46 +00:00
using MongoDB.Driver;
2020-01-08 04:41:50 +00:00
namespace Wabbajack.BuildServer.Models
{
public class NexusCacheData<T>
{
[BsonId]
public string Path { get; set; }
public T Data { get; set; }
public string Game { get; set; }
2020-01-13 04:04:46 +00:00
[BsonIgnoreIfNull]
2020-01-08 04:41:50 +00:00
public string ModId { get; set; }
public DateTime LastCheckedUTC { get; set; } = DateTime.UtcNow;
[BsonIgnoreIfNull]
public string FileId { get; set; }
2020-01-13 04:04:46 +00:00
public async Task Upsert(IMongoCollection<NexusCacheData<T>> coll)
{
await coll.FindOneAndReplaceAsync<NexusCacheData<T>>(s => s.Path == Path, this, new FindOneAndReplaceOptions<NexusCacheData<T>> {IsUpsert = true});
}
2020-01-08 04:41:50 +00:00
}
}