我有嵌入用戶的通知。在Mongoid中,我將如何實現類似的查詢。下面的查詢使用Mongdb完成:Mongoid,通知幫助
MONGODB site_name_development['users'].update(
{"_id"=>BSON::ObjectId('4ce694e672357e015a000014'),
"notifications._id"=>BSON::ObjectId('4ce694e672357e015a000017')},
{"$set"=>{"notifications.0.is_active"=>true}})
基本上,如果我有用戶Foobar。 Foobar有3種類型的通知。我想通過將is_active設置爲true來打開其中一個通知。同時所有其他通知的is_active應該設置爲false
應該執行什麼查詢?