2025-05-02 07:54:16 +08:00
|
|
|
|
using MongoDB.Bson;
|
|
|
|
|
using MongoDB.Driver;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace MongoDb.Ado.data
|
|
|
|
|
{
|
|
|
|
|
public class DeleteHandler : IMongoOperationHandler
|
|
|
|
|
{
|
2025-05-02 16:55:48 +08:00
|
|
|
|
public string operation { get; set; }
|
2025-05-04 18:39:11 +08:00
|
|
|
|
public HandlerContext context { get; set; }
|
|
|
|
|
|
2025-05-02 07:54:16 +08:00
|
|
|
|
public int Handle(IMongoCollection<BsonDocument> collection, string json)
|
|
|
|
|
{
|
|
|
|
|
var doc = BsonDocument.Parse(json);
|
|
|
|
|
var filter = doc["filter"].AsBsonDocument;
|
|
|
|
|
var result = collection.DeleteOne(filter);
|
|
|
|
|
return (int)result.DeletedCount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|