Convert code to mongoid syntax