Skip to main content

Get collection list

Gets a list of database collections

Function GetCollectionList(Val Connection, Val Base = Undefined) Export

ParameterCLI optionTypeRequiredDescription
Connection--dbcString, ArbitraryConnection or connection string
Base--dbStringDatabase name. Current database if not specified

Returns: Map Of KeyAndValue - Operation result

1C:Enterprise/OneScript code example
    Address  = "127.0.0.1:1234";
Login = "bayselonarrend";
Password = "12we...";

ConnectionParams = New Structure("authSource", "admin");
ConnectionString = OPI_MongoDB.GenerateConnectionString(Address, , Login, Password, ConnectionParams);
Connection = OPI_MongoDB.CreateConnection(ConnectionString);

Base = "test_database";

Result = OPI_MongoDB.GetCollectionList(Connection, Base);
    oint mongodb GetCollectionList \
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" \
--db "test_database"
Result
{
"result": true,
"data": {
"cursor": {
"id": 0,
"ns": "test_database.$cmd.listCollections",
"firstBatch": [
{
"name": "test_collection",
"type": "collection",
"options": {
"validator": {
"$expr": [
{
"$gte": [
"***",
"***"
]
},
{
"$lte": [
"***",
"***"
]
}
]
}
},
"info": {
"readOnly": false,
"uuid": {
"__B64_BINARY__": "j3wssnsOQ/aNkJRFcqBGkw=="
}
},
"idIndex": {
"v": 2,
"key": {
"_id": 1
},
"name": "_id_"
}
}
]
},
"ok": 1
}
}