> For the complete documentation index, see [llms.txt](https://goooqo.docs.doyto.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://goooqo.docs.doyto.win/zh/query-mapping/query-object.md).

# 查询对象定义

## 示例

```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 %}
