How to get a list of all collections in a DocumentDB document?

I have created many collections in the DocumentDB database. How to get a list of existing collections in a database?

I just started learning DocumentDb from official documentation .

+6
source share
1 answer

Short answer: you cannot get the list of collections inside the document. However, you can get a list of the collection inside the database.

Here's a look at the DocumentDB resource model: enter image description here

A look at the DocumentDB resource model โ€” Databases contain collections, which in turn contain stored procedures, triggers, UDFs, and documents.

You can request a list of collections in a given database using the DocumentDB Client or the REST API. Here is an example in .NET:

DocumentClient client = new DocumentClient(new Uri(endpoint), authKey); Database database = client.CreateDatabaseQuery("SELECT * FROM d WHERE d.id = \"[YOUR_DATABASE_ID]\"").AsEnumerable().First(); List<DocumentCollection> collections = client.CreateDocumentCollectionQuery((String)database.SelfLink).ToList(); 

Literature:

DocumentDB Resource Model and Concepts

DocumentDB.NET Code Samples

+9
source

Source: https://habr.com/ru/post/979486/


All Articles