條件比較靈活,能夠用於 db.Frist, db.Last, db.Find, db.Where 等方法。sql
指定主鍵idcode
3
字符串
sql: id = 3
string
指定一組主鍵idast
[]int{1,2,3}
map
sql: id in (1,2,3)
方法
簡單 sql查詢
"age = ?", 11
db
sql: age = 11
co
"name = ?", "user1"
sql: name = "user1"
將只查詢具備值的那些字段
&User{Name: "user1", Age: 12}
sql: name = "user1" AND age = 12
map[string]interface{}{"name": "user1", "age": 12}
sql: name = "user1" AND age = 12