是否有任何方法可以使用驱动程序的内置映射器来获取带有分页的文档?findAll()
方法接受pageState
作为一个选项,但不返回它以在下一次调用中使用它。
const result = await this.repository.findAll({ limit: 1 }, { fetchSize: 1 });
console.log(JSON.stringify(result));
返回此JSON:
{
"_rs": {
"info": {
"queriedHost": "127.0.0.1:9042",
"triedHosts": {
"127.0.0.1:9042": null
},
"speculativeExecutions": 0,
"achievedConsistency": 10,
"isSchemaInAgreement": true
},
"rows": [],
"rowLength": 0,
"columns": [
{
"name": "namespace_id",
"type": {
"code": 13,
"type": null
}
},
{
"name": "archived_at",
"type": {
"code": 15,
"type": null
}
},
{
"name": "channel_id",
"type": {
"code": 13,
"type": null
}
},
{
"name": "created_at",
"type": {
"code": 11,
"type": null
}
},
{
"name": "department_id",
"type": {
"code": 13,
"type": null
}
},
{
"name": "id",
"type": {
"code": 13,
"type": null
}
},
{
"name": "identifier_type",
"type": {
"code": 13,
"type": null
}
},
{
"name": "identifier_value",
"type": {
"code": 13,
"type": null
}
},
{
"name": "last_assignee_id",
"type": {
"code": 9,
"type": null
}
}
],
"pageState": null
},
"_info": {
"keyspace": "omnichannel",
"tables": [
{
"name": "ticket_by_archive_time",
"isView": false
},
{
"name": "ticket_by_id",
"isView": false
},
{
"name": "ticket_by_identifier",
"isView": false
}
],
"_mappings": {},
"_columns": {},
"_documentProperties": {}
},
"_isEmptyLwt": false,
"length": 0,
"pageState": null
}
问题是传递limit
选项,将其删除并仅使用fetchSize
解决了问题。