Mongodb / Mongoid - which means {: multi => true}

Regarding this question: With Mongoid, can I "update_all" display a value in an array field for multiple records at the same time?

I would like to ask:

  • What is the purpose {:multi => true}here?
  • Is it possible to output a value to an array when update_allthrough mongoid now? because the question is in 2010.

Thank.

+2
source share
2 answers

The documentation for the MongoDB update method states the following:

multi - indicates whether all criteria for matching documents should be updated, not just one. May be useful with the $ operators below.

, multi - , update_all , .

: - Mongoid . . :

User.where(:gender => "Male").update_all(:title => "Mr")

, , MongoDB , Mongoid update_all $set ( , ).

, , , ( shingara!):

User.collection.update( 
  {'$in' => {:gender => 'Male'}}, 
  {'$push' => {:titles => 'Mr'}},
  {:multi => true}
)
+3

usecase - Mongodb (http://docs.mongodb.org/master/MongoDB-sharding-guide.pdf). , , , _id, . multi true, .

0

All Articles