I have the follow raw mongo query that I want to execute directly in my Rails controller:
db.user_places.update({place_id: destroy_model.id}, {$set: {place_id: keep_model.id}}, false, true)
For sequel, I was using ActiveRecord::Base.connection.execute(sql)
to execute my sql queries.
What's the equivalent way of doing this using MongoDB/mongoid gem? I've tried following How to fire raw MongoDB queries directly in Ruby, but I'm not using MongoMapper.
Thank you.
Edit: My solution to this problem was to just run the following from Mongoid documentation:
UserPlace.where(place_id: destroy_model.id).update_all(place_id: keep_model.id)
This will generate the raw mongo query above and execute it in ActiveRecord fashion.