From 1e863551ae57211bc5e2295d85cf50e47623978f Mon Sep 17 00:00:00 2001 From: AlianBlank Date: Thu, 4 Jul 2024 21:12:45 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]1.=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E5=88=A0=E9=99=A4=E6=B2=A1=E6=9C=89=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DbService/MongoDB/MongoDbService.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/DataBaseServer/GameFrameX.DBServer/DbService/MongoDB/MongoDbService.cs b/DataBaseServer/GameFrameX.DBServer/DbService/MongoDB/MongoDbService.cs index 5239700e..1264c7b7 100644 --- a/DataBaseServer/GameFrameX.DBServer/DbService/MongoDB/MongoDbService.cs +++ b/DataBaseServer/GameFrameX.DBServer/DbService/MongoDB/MongoDbService.cs @@ -260,14 +260,13 @@ public async void Open(string url, string dbName) /// public async Task DeleteAsync(Expression> filter) where TState : ICacheState, new() { - // var newFilter = Builders.Filter.Where(filter); - // var collectionName = typeof(TState).Name; - // var collection = CurrentDatabase.GetCollection(collectionName); - // state.DeleteTime = DateTime.UtcNow; - // state.IsDeleted = true; - // var result = await collection.ReplaceOneAsync(filter, state, ReplaceOptions); - // return result.ModifiedCount; - return -1; + var collection = GetCollection(); + var state = await FindAsync(filter); + var newFilter = Builders.Filter.Eq(CacheState.UniqueId, state.Id); + state.DeleteTime = TimeHelper.UnixTimeSeconds(); + state.IsDeleted = true; + var result = await collection.ReplaceOneAsync(newFilter, state, ReplaceOptions); + return result.ModifiedCount; } ///