O
O
odd-look2015-07-08 12:57:52
JavaScript
odd-look, 2015-07-08 12:57:52

How to set the same value to the ObjectID array?

There is an array of ObjectID. I want to change a certain field in every object. I would not like to write a crutch, maybe there is an elegant solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2015-07-08
@odd-look

MyCollection.update({ _id: { $in: objectIdArray } }, {$set: {my_field: 'some new value'}}).then(console.log.bind(console))

$set
$in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question