0
我目前正在更新一个Rails应用到Mongoid 5.我在更新一些使用废弃方法(find_and_modify)的代码时遇到问题。任何帮助,将不胜感激。Mongoid find_and_modify已弃用
在Mongoid 4,我有这样的方法找到并UPSERT:
LineItem.where({
date: Date.today,
location: "Location",
department: "Department"
}).find_and_modify({
"$set" => {
hours: 8,
updated_at: Time.current
},
"$setOnInsert" => {
account_id: ObjectId("5739f4534f4e48b2aa00091c"),
date: Date.today,
location: "Location",
department: "Department",
created_at: Time.current
}
}, upsert: true)
使用Mongoid 5,什么是相同呢?
谢谢。