GoooQo v0.2.3
HomeGitHubDemo
English
English
  • Introduction
  • Quickstart
  • API
    • Connection
    • Transaction
    • CRUD
    • Association Service
  • Entity Mapping
    • Entity Object
    • Related Entities
  • Query Mapping
    • Query Object
      • Predicate-Suffix Field
      • Logic-Suffix Field
      • Subquery Field
      • E-R Query Field
      • Custom Condition Field
    • Page Query
  • Aggregate Query
    • View Object
    • Having
    • Natural Join
    • Outer Join
    • Nested View
  • Advanced
    • Dialect
    • Locking
  • Related Resources
    • Articles
      • From ORM to OQM: An Object-Only SQL Construction Solution
      • Introduction to GoooQo
      • How to express `select * from user where id = ? or name = ? and age = ?` in GoooQo
Powered by GitBook
On this page
  • Mapping
  • Example

Was this helpful?

Edit on GitHub
  1. Query Mapping
  2. Query Object

Custom Condition Field

Mapping

For types of query conditions that are not currently supported, GoooQo uses the tag condition to directly write native SQL conditions:

Example

type UserQuery struct {
    PageQuery
    Account *string `condition:"(username = ? OR email = ?)"`
    //...
}

Output SQL:

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

PreviousE-R Query FieldNextPage Query

Last updated 8 months ago

Was this helpful?