How to update and upsert multiple documents in MongoDB using C# Drivers

后端 未结 6 1879
清酒与你
清酒与你 2020-12-10 12:37

I am using MongoDB 2, and I want to update multiple documents and upsert a value like processed:true into the collection. But MongoDB c# api only allows us to

6条回答
  •  Happy的楠姐
    2020-12-10 13:23

    You cannot do it in one statement.

    You have two options

    1) loop over all the objects and do upserts

    2) figure out which objects have to get updated and which have to be inserted then do a batch insert and a multi update

提交回复
热议问题