# Query Object

### Example

```go
type UserQuery struct {
    PageQuery
    IdGt     *int64
    IdIn     *[]int64
    ScoreLt  *int
    MemoNull *bool
    MemoLike *string
    Deleted  *bool
    UserOr   *[]UserQuery
    
    ScoreGtAvg *UserQuery `subquery:"select:avg(score),from:UserEntity"`
    ScoreLtAny *UserQuery `subquery:"select:score,from:UserEntity"`
    ScoreLtAll *UserQuery `subquery:"select:score,from:UserEntity"`
}
```

### Query Interface

The query object needs to implement the `Query` interface for the construction of paging clause and sorting clause:&#x20;

```go
package core

type Query interface {
    GetPageNumber() int
    GetPageSize() int
    CalcOffset() int
    GetSort() *string
    NeedPaging() bool
}
```

The `PageQuery` struct provides a standard implementation for the query structs.&#x20;

{% content-ref url="/spaces/caxovyAjMzGHxhZgzo8F/pages/WhXxQxwyMwh5iXBKypK7" %}
[Page Query](/query-mapping/page-query.md)
{% endcontent-ref %}

### Fields Definition

The query object is used to map the dynamic part of the SQL statements, such as filter conditions, pagination, and sorting.

Each field in the query object is used to map a query condition.

Check the following docs for how to define the fields in GoooQo:

{% content-ref url="/spaces/caxovyAjMzGHxhZgzo8F/pages/Ku4ZcaLqf5MB6ZMsvyp6" %}
[Predicate-Suffix Field](/query-mapping/query-object/predicate-suffix-field.md)
{% endcontent-ref %}

{% content-ref url="/spaces/caxovyAjMzGHxhZgzo8F/pages/ifm6kLL2owkfw9DC6rpx" %}
[Logic-Suffix Field](/query-mapping/query-object/logic-suffix-field.md)
{% endcontent-ref %}

{% content-ref url="/spaces/caxovyAjMzGHxhZgzo8F/pages/JDwZe7p4MFhiM23xD1Id" %}
[Subquery Field](/query-mapping/query-object/subquery-field.md)
{% endcontent-ref %}

{% content-ref url="/spaces/caxovyAjMzGHxhZgzo8F/pages/Xa80wuFVpJgGOm8kFJ6Y" %}
[E-R Query Field](/query-mapping/query-object/er-query-field.md)
{% endcontent-ref %}

{% content-ref url="/spaces/caxovyAjMzGHxhZgzo8F/pages/v1icJZJQQGyYRIvaZ2F8" %}
[Custom Condition Field](/query-mapping/query-object/custom-condition-field.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://goooqo.docs.doyto.win/query-mapping/query-object.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
