update_all syntax?

486 views
Skip to first unread message

Amit Kumar

unread,
Mar 8, 2011, 4:14:10 AM3/8/11
to mon...@googlegroups.com
Hi,

could someone shed light on the update_all syntax?

when i use Model.update_all(update, conditions) then mongoid adds conditions to the documents as attributes... :O

Durran Jordan

unread,
Mar 8, 2011, 9:34:49 AM3/8/11
to mon...@googlegroups.com
This updates EVERY document in the database:

Model.update_all(first_name: "Emmanuel")

This updates by conditions:

Model.where(last_name: "Zorg").and(:age.gt => 40).update_all(first_name: "Emmanuel")

2011/3/8 Amit Kumar <i.strik...@gmail.com>

Amit Kumar

unread,
Mar 8, 2011, 9:36:06 AM3/8/11
to mon...@googlegroups.com
update_all works with a single query or multiple queries???
Regards,
Amit Kumar
http://www.itsamit.com
fin...@itsamit.com

Durran Jordan

unread,
Mar 8, 2011, 9:47:11 AM3/8/11
to mon...@googlegroups.com
It peforms a single $set with :multi => true operation under the covers.

2011/3/8 Amit Kumar <i.strik...@gmail.com>
Reply all
Reply to author
Forward
0 new messages