I call the Elements with find() method and after than i want to update all. For example:
db.collection.find().limit(10).update({$set: {'column' : 'value'}});
how can i fix this?
I call the Elements with find() method and after than i want to update all. For example:
db.collection.find().limit(10).update({$set: {'column' : 'value'}});
how can i fix this?
By default it updates only the first 1 document it found. You need to add multi = true as an option to update() to update all. Unfortunately, update() doesn't have limit option so you can limit it to 10.
You might have to do find() with limit first and then update each document separately like mentioned in this post:
How to limit number of updating documents in mongodb
If you want to apply update to every document in collection, use
{multi:true}
optionFor more detail, see collection.update
However, if you want to update selected number of documents, you'll be taking longer route.