Get document batch
Gets the next batch of cursor documents
- Parameters
- Advanced call ?
Function GetDocumentBatch(Val Connection, Val Collection, Val CursorID, Val Base = Undefined, Val BatchSize = Undefined, Val Waiting = Undefined) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Connection | - | String, Arbitrary | ✔ | Connection or connection string |
| Collection | - | String | ✔ | Collection name |
| CursorID | - | Number | ✔ | Cursor ID |
| Base | - | String | ✖ | Database name. Current database if not specified |
| BatchSize | - | Number | ✖ | Amount of records in the batch |
| Waiting | - | Number | ✖ | Maximum lock time during awaitData (in ms.) |
Returns
Map Of KeyAndValue - Operation result
| Parameter | Description |
|---|---|
| addin_mode | Manual selection of external component connection mode (for 1C): Isolated, NotIsolated |
Caution
NOCLI: this method is not available in CLI version
1C:Enterprise/OneScript code example
Address = "127.0.0.1:1234";
Login = "bayselonarrend";
Password = "12we...";
Base = "main";
ConnectionParams = New Structure("authSource", "admin");
ConnectionString = OPI_MongoDB.GenerateConnectionString(Address, , Login, Password, ConnectionParams);
Connection = OPI_MongoDB.CreateConnection(ConnectionString);
Collection = "new_collection";
Filter = New Structure("stringField", "Text");
Sort = New Structure("doubleField", -1);
Parameters = New Structure("limit,batchSize", 2, 1);
Cursor = OPI_MongoDB.GetCursor(Connection, Collection, Base, Filter, Sort, Parameters);
If Not Cursor["result"] Then
Raise Cursor["error"];
EndIf;
Cursor = Cursor["data"]["cursor"];
DocsArray = Cursor["firstBatch"];
CursorID = Cursor["id"];
ContinueGetting = CursorID > 0;
While ContinueGetting Do
Result = OPI_MongoDB.GetDocumentBatch(Connection, Collection, CursorID, Base); // <---
If Not Result["result"] Then
Raise Result["error"];
EndIf;
ContinueGetting = Result["data"]["cursor"]["id"] > 0;
For Each Record In Result["data"]["cursor"]["nextBatch"] Do
DocsArray.Add(Record);
EndDo;
EndDo;
Result
{
"result": true,
"data": {
"cursor": {
"nextBatch": [
{
"_id": "6a15a6be6edd1cf4d2a504a5",
"stringField": "Text",
"intField": 200,
"doubleField": 123.456,
"boolField": true,
"arrayField": [
"Value1",
"Value2"
],
"docField": {
"text": "Text",
"number": 10
},
"dateField": "2026-05-26T13:57:18Z",
"nullField": null
}
],
"id": 0,
"ns": "main.new_collection"
},
"ok": 1
}
}