using MongoDB.Driver;
using System;
using System.Collections.Generic;
namespace Bootstrap.DataAccess.MongoDB
{
///
///
///
public class Log : DataAccess.Log
{
///
///
///
///
public override IEnumerable Retrieves() => DbManager.Logs.Find(l => l.LogTime >= DateTime.Now.AddDays(-7)).ToList();
///
/// 删除日志信息
///
///
///
private static void DeleteLogAsync() => System.Threading.Tasks.Task.Run(() => DbManager.Logs.DeleteMany(log => log.LogTime < DateTime.Now.AddDays(-7)));
///
///
///
///
///
public override bool Save(DataAccess.Log log)
{
log.LogTime = DateTime.Now;
DbManager.Logs.InsertOne(log);
return true;
}
}
}