当 where 字典的值为数组时 gorm 会自动转换为条件 IN 查询
go
where := map[string]interface{}{}
where["id"] = [1,2,3]
where["name"] = "zhangsan"
type userList struct {
Id int "gorm:'id'"
Name string "gorm:'name'"
}
Table.Debug().where(where).find(&user).Error
生成的sql语句 select * form user where id in (1,2,3)and name = "zhangsan"