gorm 條件模式

條件比較靈活,能夠用於 db.Frist, db.Last, db.Find, db.Where 等方法。sql

單個整數

指定主鍵idcode

3字符串

sql: id = 3string

一組整數

指定一組主鍵idast

[]int{1,2,3}map

sql: id in (1,2,3)方法

字符串開頭,後跟參數

簡單 sql查詢

"age = ?", 11db

sql: age = 11co

"name = ?", "user1"

sql: name = "user1"

結構

將只查詢具備值的那些字段

&User{Name: "user1", Age: 12}

sql: name = "user1" AND age = 12

映射 map[string]interface{}

map[string]interface{}{"name": "user1", "age": 12}

sql: name = "user1" AND age = 12

相關文章
相關標籤/搜索