我有一个表(设备),我正在使用Ruby访问。如果满足以下两个条件,我想删除一行:
{:user_id => params[:user_id]}
和
{:reg_token => params[:reg_token]}
但是,我不确定我是否知道如何正确使用AND
。我正在尝试遵循本指南:
http://sequel.jeremyevans.net/rdoc/files/doc/dataset_filtering_rdoc.html
if Device.where{Sequel.&({:user_id => params[:user_id]}, {:reg_token => params[:reg_token]})}.count > 0
# device = Device.where((:user_id => params[:user_id]) & (:reg_token => params[:reg_token])).delete
device = Device.where{Sequel.&({:user_id => params[:user_id]}, {:reg_token => params[:reg_token]})}.delete
end
答案 0 :(得分:0)
我只想链接where
子句:
devices = Device.where(user_id: params[:user_id]).where(reg_token: params[:reg_token])
devices.delete_all