Firestore 分页:如何为 REST 定义 'startAt'-cursor?

Firestore Pagination: how to define 'startAt'-cursor for REST?

我正在尝试使用游标和 'startAt' 对 Firestore 的 REST 请求进行分页。根据 Paginate-documentation, the cursor should equal to the last document of the previous query. As the REST-documentation 没有示例,我尝试通过将整个文档作为光标插入 startAt-object 来 运行 它;像这样:

POST https://firestore.googleapis.com/v1/PROJECT-NAME/databases/(default)/documents/organizations/testManyInstructions:runQuery
{
    "structuredQuery": {
        "from": [
            {
                "collectionId": "instructions"
            }
        ],
        "where": {
            "fieldFilter": {
                "field": {
                    "fieldPath": "belongsToDepartementID"
                },
                "op": "EQUAL",
                "value": {
                    "stringValue": "toplevel-document-id"
                }
            }
        },
        "orderBy": [ 
          { 
              "field": { 
                  "fieldPath": "instructionNumber" 
              }, 
              "direction": "ASCENDING" 
          } 
        ], 
        "startAt": {
            "values": [{
              "document": {
                  "name": "projects/PROJECT-NAME/databases/(default)/documents/organizations/testManyInstructions/instructions/i0",
                  "fields": {
                      "checkbox": {
                          "booleanValue": false
                      },
                      "retrainTimespanDays": {
                          "integerValue": "365000"
                      },
                      "approvedByName": {
                          "stringValue": ""
                      },
                      "instructionNumber": {
                          "stringValue": "instr. 0"
                      },
                      "instructionCurrentRevision": {
                          "stringValue": "A"
                      },
                      "instructionCurrentRevisionPublishingDate": {
                          "timestampValue": "1999-01-01T00:00:00Z"
                      },
                      "instructionFileURL": {
                          "stringValue": ""
                      },
                      "instructionTitle": {
                          "stringValue": "dummy Title0"
                      },
                      "instructionFileUploadDate": {
                          "timestampValue": "1999-01-01T00:00:00Z"
                      },
                      "belongsToDepartementID": {
                          "stringValue": "toplevel-document-id"
                      },
                      "approvedByEmailAdress": {
                          "stringValue": ""
                      }
                  },
                  "createTime": "2022-02-18T13:55:42.807103Z",
                  "updateTime": "2022-02-18T13:55:42.807103Z"
              }
            }
          ]
        },
        "limit": 5
    }
}
    {
        "error": {
            "code": 400,
            "message": "Invalid JSON payload received. Unknown name \"document\" at 'structured_query.start_at.values[0]': Cannot find field.",
            "status": "INVALID_ARGUMENT",
            "details": [
                {
                    "@type": "type.googleapis.com/google.rpc.BadRequest",
                    "fieldViolations": [
                        {
                            "field": "structured_query.start_at.values[0]",
                            "description": "Invalid JSON payload received. Unknown name \"document\" at 'structured_query.start_at.values[0]': Cannot find field."
                        }
                    ]
                }
            ]
        }
    }
]

请指教,如何在 startAt 对象中正确设置光标。

我已经 运行 使用偏移量而不是 startAt 的类似查询,所以我尝试修改并让它工作。这是我使用的其余 api 文档。 startAt 需要一个 Cursor 对象,它是一个值数组。 https://firebase.google.com/docs/firestore/reference/rest/v1/StructuredQuery https://firebase.google.com/docs/firestore/reference/rest/v1/Cursor https://firebase.google.com/docs/firestore/reference/rest/Shared.Types/ArrayValue#Value

我也希望有一个例子!

    "startAt": {
        "values": [{
            "stringValue": "Cr"
        }]
    },
    "orderBy": [{
        "field": {
            "fieldPath": "Summary"
        }
    }],

祝你好运!