# 查询对象定义

## 示例

```go
type UserQuery struct {
	PageQuery
	ScoreLt   *int
	MemoStart *string
	// ...
}
```

## 查询接口

查询对象需要实现查询接口，以便构建分页子句和排序子句：

```go
package core

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

GoooQo为查询接口提供了一个标准实现`PageQuery`：

{% content-ref url="/spaces/LwvgPEM32oQWVvvI7ep3/pages/7wI5Tx3t5Jl0wPwutQyV" %}
[分页排序对象](/zh/query-mapping/page-query.md)
{% endcontent-ref %}

## 字段定义

查询对象用于映射 SQL 语句的动态部分，例如过滤条件、分页和排序。

查询对象中的每个字段用于映射一组查询条件。

查看以下文档以了解如何定义查询对象中的字段：

{% content-ref url="/spaces/LwvgPEM32oQWVvvI7ep3/pages/GfvGP08it7ljJxkyX6HQ" %}
[谓词后缀字段](/zh/query-mapping/query-object/predicate-suffix-field.md)
{% endcontent-ref %}

{% content-ref url="/spaces/LwvgPEM32oQWVvvI7ep3/pages/27O85XWdQG0qXL3c2v0L" %}
[逻辑后缀字段](/zh/query-mapping/query-object/logic-suffix-field.md)
{% endcontent-ref %}

{% content-ref url="/spaces/LwvgPEM32oQWVvvI7ep3/pages/IyQiTNnV0NzfM0DWfklE" %}
[子查询字段](/zh/query-mapping/query-object/subquery-field.md)
{% endcontent-ref %}

{% content-ref url="/spaces/LwvgPEM32oQWVvvI7ep3/pages/2G08mVRgUT4dLZPzjdiL" %}
[ER关系字段](/zh/query-mapping/query-object/er-query-field.md)
{% endcontent-ref %}

{% content-ref url="/spaces/LwvgPEM32oQWVvvI7ep3/pages/mZJ5Rmz3sN3uSRYfPXJH" %}
[自定义字段](/zh/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/zh/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.
