我正在使用Sequel gem批量更新MySql中的用戶。如何在批量更新中使用Sequel Gem返回更新的記錄
users = Users.filter(:id => ids).all
raise if users.nil?
updated_users = Users.filter(:id => addon_ids).update({deleted: 1, moderator_id: moderator_id})
p updated_users
# => 3
「更新[刪除]應該返回受影響的行數......」
因此上述行爲的預期,但我的問題是,我怎麼能得到續集寶石返回更新的記錄,而不是受影響的記錄數量?
我期待這種行爲:
users = Users.filter(:id => ids).all
raise if users.nil?
updated_users = Users.filter(:id => addon_ids).update({deleted: 1, moderator_id: moderator_id})
p updated_users
# => [#<Users @values={:id=>1, :moderator_id=>"testuser", :deleted=>1}>, #<Users @values={:id=>2, :moderator_id=>"testuser", :deleted=>1}>, #<Users @values={:id=>3, :moderator_id=>"testuser", :deleted=>1}>]