1

I'm working with the mongo-c-driver and I have a doubt with the BSON library. 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). 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

Héctor
  • 399
  • 3
  • 16

1 Answers1

0

You can update or delete a field with the 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.

rulezzer
  • 55
  • 8
  • 1
    I'm talking about documents in memory created by the driver with [bson_new](http://mongoc.org/libbson/current/bson_new.html). Not already stored documents in mongoDB. – Héctor Apr 20 '20 at 06:58