mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 23:13:42 +08:00
Update mongodb
This commit is contained in:
parent
5d6dc94b50
commit
4f2d7550fc
@ -12,12 +12,8 @@ namespace MongoDb.Ado.data
|
||||
public object Handle(IMongoCollection<BsonDocument> collection, string json)
|
||||
{
|
||||
var filter = string.IsNullOrWhiteSpace(json) ? FilterDefinition<BsonDocument>.Empty : BsonDocument.Parse(json);
|
||||
|
||||
// 设置投影排除 "_id" 字段,确保返回的结果不包含 _id 字段
|
||||
var projection = Builders<BsonDocument>.Projection.Exclude("_id");
|
||||
|
||||
// 执行查询并限制返回一条记录
|
||||
var document = collection.Find(filter).Project(projection).FirstOrDefault();
|
||||
var document = collection.Find(filter).FirstOrDefault();
|
||||
|
||||
// 如果查询到结果且文档非空,则获取第一个字段的值
|
||||
if (document != null && document.Elements.Any())
|
||||
|
Loading…
Reference in New Issue
Block a user