In GORM, queries are built with non-zero fields of the struct
. If there are
fields with zero values, they are not considered and not included in query
conditions.
// Age is of type `int` and `0` is the zero value for `int`.
db.Where(&User{Name: "jinzhu", Age: 0}).First(&users)
db.Where(map[string]interface{}{"name": "jinzhu", "age": 0}).First(&users)