with post_id that was up voted or down voted by user_id # Find post with post_id that was up voted or down voted by user_id query query = = { { 'post_id' 'post_id' => post_id, => post_id, '$or' '$or' => => { { 'votes.up' 'votes.up' => user_id, => user_id, 'votes.down' 'votes.down' => user_id } => user_id } } } # Pull user_id from both votes.up_ids and votes.down_ids # Pull user_id from both votes.up_ids and votes.down_ids # and update votes.point and votes.count # and update votes.point and votes.count update update = = { { '$pull' '$pull' => => { { 'votes.up' 'votes.up' => user_id, => user_id, 'votes.down' 'votes.down' => user_id => user_id }, }, '$inc' '$inc' => => { { 'votes.point' 'votes.point' => => - -POINT[value], POINT[value], 'votes.count' 'votes.count' => => - -1 1 } } } } # Validate, update and get result # Validate, update and get result post post = = Post.collection.find_and_modify( Post.collection.find_and_modify( :query :query => query, => query, :update :update => update, => update, :new :new => => true true # return post after update votes data # return post after update votes data ) ) end end Mongo one request