简体   繁体   English

mongo-c-driver中的bson:更新已存在字段的值

[英]bson in mongo-c-driver: update value of already existent field

I'm working with the mongo-c-driver and I have a doubt with the BSON library.我正在使用 mongo-c-driver,但我对 BSON 库有疑问。 As you can see here , there are a lot of functions to append data to already existent bson document (We are talking about bson documents in memory, not stored in the database).如您所见, append数据到已经存在的 bson 文档有很多功能(我们说的是 memory 中的 bson 文档,不存储在数据库中)。 But I can't find one to update or delete an already existent field.但是我找不到一个来更新或删除已经存在的字段。 There is a way to modify already existent fields?有没有办法修改已经存在的字段?

Best regards, thanks for your time,最好的问候,感谢您的时间,

Héctor赫克托

You can update or delete a field with the mongoc_collection_update_one() function.您可以使用mongoc_collection_update_one() function 更新或删除字段。 The "$set" and "$unset" operators should be good enough for simple fields (or "$push" and "$pull" for arrays), otherwise there is the complete list of operators here . "$set""$unset"运算符对于简单的字段应该足够好(或者对于数组来说是"$push""$pull" ),否则这里有完整的运算符列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM