---
sidebar_position: 5
description: Get cursor  and other functions to work with MongoDB in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, MongoDB]
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Get cursor 
 Gets a cursor for batch retrieval of collection documents



`Function GetCursor(Val Connection, Val Collection, Val Base = Undefined, Val Filter = Undefined, Val Sort = Undefined, Val Parameters = Undefined) Export`

  | Parameter | CLI option | Type | Required | Description |
  |-|-|-|-|-|
  | Connection | - | String, Arbitrary | &#x2714; | Connection or connection string |
  | Collection | - | String | &#x2714; | Collection name |
  | Base | - | String | &#x2716; | Database name. Current database if not specified |
  | Filter | - | Structure Of KeyAndValue | &#x2716; | Document filter |
  | Sort | - | Structure Of KeyAndValue | &#x2716; | Selection sorting |
  | Parameters | - | Structure Of KeyAndValue | &#x2716; | Additional retrieval parameters |

  
  Returns:  Map Of KeyAndValue - Operation result


:::caution
**NOCLI:** this method is not available in CLI version
:::
<br/>


```bsl title="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);

    Result = OPI_MongoDB.GetCursor(Connection, Collection, Base, Filter, Sort, Parameters);
```
 



```json title="Result"
{
 "result": true,
 "data": {
  "cursor": {
   "firstBatch": [
    {
     "_id": "6939c896f1fedecc48aa21b9",
     "stringField": "Text",
     "oidField": "63ceed18f71dda7d8cf21e8e",
     "jsField": "const result = [1, 2, 3].map(x => x * 2).filter(x => x > 3);",
     "symbolField": "Y",
     "int32Field": 10,
     "int64Field": 1000,
     "doubleField": 124.456,
     "boolField": true,
     "dateField": "2025-11-15T10:55:41Z",
     "tsField": "Timestamp(1765394580, 0)",
     "regexpField": "/[a-z]+@[a-z]+\\.[a-z]+/i",
     "binaryField": {
      "__B64_BINARY__": "VGV4dA=="
     },
     "nullField": null,
     "minkeyField": "***",
     "maxkeyField": "***",
     "docField": {
      "code": "const result = 1",
      "number": 10
     },
     "arrayField": [
      "***",
      "***"
     ]
    }
   ],
   "id": 3617426790793489632,
   "ns": "main.new_collection"
  },
  "ok": 1
 }
}
```
