Predicate-Suffix Field

Mapping

GoooQo uses a predicate suffix mapping method to map fields in query objects to basic query conditions. Each basic query condition consists of a column name, a comparison operator, and a value. The format of the field name in the query object is a column name plus one of the comparison operator alias. All assigned fields in a query instance will be mapped to the corresponding query conditions and spliced ​​into a query clause.

Examples

Here are two examples of the predicate-suffix field mapping:

userQuery := UserQuery{Deleted: P(true)}
users, err := userDataAccess.Query(ctx, userQuery)
// SQL="SELECT id, name, score, memo, deleted FROM t_user WHERE deleted = ?" args="[true]"

userQuery := UserQuery{IdIn: &[]int64{1, 4, 12}, Deleted: P(true)}
users, err := userDataAccess.Query(ctx, userQuery)
// SQL="SELECT id, name, score, memo, deleted FROM t_user WHERE id IN (?, ?, ?) AND deleted = ?" args="[1 4 12 true]"

Check the predicate suffix table for all supported suffixes by GoooQo.

Predicate Suffix Table

Last updated