R
R
Roman Andreevich2019-10-27 14:42:49
MongoDB
Roman Andreevich, 2019-10-27 14:42:49

How to update multiple documents from the same MongoDb collection?

Colleagues, good day, how to update several documents from the collection, the meaning is this:
there is an array of document identifiers, and each document needs to add the property state: true.
Thank you in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2019-10-27
@RomanDillerNsk

db.docs.updateMany(
  { _id: { $in: ['id1', 'id2', 'id3'] } },
  { $set: { state: true } }
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question