+

MongoDB Connector Additional Configuration Information - Mule 4

Additional Results in the Response of the Execute Command Operation

The Execute Command operation returns one page of results. If an execution returns a cursor reference, invoke the getMore command as needed to traverse subsequent pages of results.

Suppose executeCommand is invoked with the following command value:

{
	"find": ("test"),
	"skip": 0,
	"batchSize": 10
}

The executeCommand returns a result like this:

{
  "cursor": {
    "firstBatch": [
      {
        "_id": {
          "$oid": "..."
        },
        "meta": {
          "view": {
            "id": 1,
//            ...
           }
//         ,{ ... }, ...
        }
//....
      }
    ],
    "id": 9041685167132828464,
    "ns": "test.test"
  },
  "ok": 1.0
}

To get additional results until there are none left, use the getMore command to retrieve the next page of results:

{
	"getMore": 9041685167132828464,
	"collection" : "test",
	"batchSize": 10
}

The results of the getMore command include a cursor ID to use in subsequent getMore commands.

Was this article helpful?

💙 Thanks for your feedback!

View on GitHub