Groups
Sign in
Groups
Mongoid
Conversations
About
Send feedback
Help
update_all syntax?
486 views
Skip to first unread message
Amit Kumar
unread,
Mar 8, 2011, 4:14:10 AM
3/8/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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 AM
3/8/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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 AM
3/8/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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 AM
3/8/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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