mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-21 02:58:05 +08:00
Update Mongodb
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace MongoDb.Ado.data
|
||||
{
|
||||
public class UpdateHandler : IMongoOperationHandler
|
||||
{
|
||||
public int Handle(IMongoCollection<BsonDocument> collection, string json)
|
||||
{
|
||||
var doc = BsonDocument.Parse(json);
|
||||
var filter = doc["filter"].AsBsonDocument;
|
||||
var update = doc["update"].AsBsonDocument;
|
||||
var result = collection.UpdateOne(filter, update);
|
||||
return (int)result.ModifiedCount;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user