File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
DataBaseServer/GameFrameX.DBServer/DbService/MongoDB Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -260,14 +260,13 @@ public async void Open(string url, string dbName)
260260 /// <returns></returns>
261261 public async Task < long > DeleteAsync < TState > ( Expression < Func < TState , bool > > filter ) where TState : ICacheState , new ( )
262262 {
263- // var newFilter = Builders<TState>.Filter.Where(filter);
264- // var collectionName = typeof(TState).Name;
265- // var collection = CurrentDatabase.GetCollection<TState>(collectionName);
266- // state.DeleteTime = DateTime.UtcNow;
267- // state.IsDeleted = true;
268- // var result = await collection.ReplaceOneAsync(filter, state, ReplaceOptions);
269- // return result.ModifiedCount;
270- return - 1 ;
263+ var collection = GetCollection < TState > ( ) ;
264+ var state = await FindAsync ( filter ) ;
265+ var newFilter = Builders < TState > . Filter . Eq ( CacheState . UniqueId , state . Id ) ;
266+ state . DeleteTime = TimeHelper . UnixTimeSeconds ( ) ;
267+ state . IsDeleted = true ;
268+ var result = await collection . ReplaceOneAsync ( newFilter , state , ReplaceOptions ) ;
269+ return result . ModifiedCount ;
271270 }
272271
273272 /// <summary>
You can’t perform that action at this time.
0 commit comments