1
批量更新都不再工作,我有以下幾點:Mongoid 3批量更新升級到Mongoid 3.在Mongoid 2後
Shift.where(
:account_id => current_account.id,
:location => self.department.location.name,
:department => self.department.name,
:position => self.name_was,
:color => self.color_was,
:date.gte => Date.current
).update_all(position: self.name, color: self.color)
我知道準則返回結果,但它不再更新的文件。這裏是在Mongoid 3中的聲明:
Shift.where(
:account_id => current_account.id,
:location => self.department.location.name,
:department => self.department.name,
:position => self.name_was,
:color => self.color_was,
:date.gte => Date.current
).update(position: self.name, color: self.color)
我正在運行Rails 3.2.7和Mongoid 3.0.3。有什麼改變,我不知道?此處還有日誌條目:
MOPED: 127.0.0.1:27017 UPDATE database=development collection=shifts selector={"$query"=>{"account_id"=>"5017e8774f4e481fe3000001", "location"=>"Downtown", "department"=>"Cashes", "position"=>"Cash 1", "date"=>{"$gte"=>2012-08-01 00:00:00 UTC}}, "$orderby"=>{"start_at"=>1}} update={"$set"=>{:position=>"Cash A", :color=>"#42ed23"}} flags=[:multi] (0.2141ms)
但是,在數據庫中沒有任何更新。
不幸的是,我知道這不是問題。我已經運行沒有更新的地方,它確實返回結果。 – Dowker 2012-08-03 12:42:37