Get documents
Gets collection documents
- Parameters
- Advanced call ?
Function GetDocuments(Val Connection, Val Collection, Val Base = Undefined, Val Filter = Undefined, Val Sort = Undefined, Val Parameters = Undefined) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Connection | --dbc | String, Arbitrary | ✔ | Connection or connection string |
| Collection | --coll | String | ✔ | Collection name |
| Base | --db | String | ✖ | Database name. Current database if not specified |
| Filter | --query | Structure Of KeyAndValue | ✖ | Document filter |
| Sort | --sort | Structure Of KeyAndValue | ✖ | Selection sorting |
| Parameters | --params | Structure Of KeyAndValue | ✖ | Additional retrieval parameters |
Returns
Map Of KeyAndValue - Operation result
| Parameter | Description |
|---|---|
| addin_mode | Manual selection of external component connection mode (for 1C): Isolated, NotIsolated |
| dontwait | Creates a background job and returns its data (for 1C and OneScript only) |
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";
// __4 = $
Filter = New Structure("stringField,doubleField", "Text", New Structure("__4gte, __4lte", 100, 150));
Sort = New Structure("doubleField", -1);
Parameters = New Structure("limit", 2);
Result = OPI_MongoDB.GetDocuments(Connection, Collection, Base, Filter, Sort, Parameters);
- Bash
- CMD/Bat
# JSON data can also be passed as a path to a .json file
oint mongodb GetDocuments \
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" \
--coll "new_collection" \
--db "main" \
--query "{'stringField':'Text','doubleField':'999'}"
:: JSON data can also be passed as a path to a .json file
oint mongodb GetDocuments ^
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" ^
--coll "new_collection" ^
--db "main" ^
--query "{'stringField':'Text','doubleField':'999'}"
Result
{
"result": true,
"data": [
{
"_id": "6a15a6be6edd1cf4d2a504a6",
"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(1779803838, 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": [
"A",
"<<MinKey>>"
]
},
{
"_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
}
]
}