Get All documents in a Collection CosmosDb

MicroMan

I would like to return all documents in a collection for CosmosDb

My code is as follows

 client.CreateDocumentQuery(UriFactory.CreateDocumentUri(dbName, colName,"id")).ToList();

It is not working. I can find a specific document but not all

Thanks

Nick Chapsas

UriFactory.CreateDocumentUri creates a Uri for a document specific query.

What you want is all documents in a collection so what you need to create is to create a collection Uri. You can do that by using UriFactory.CreateDocumentCollectionUri(DatabaseName, CollectionName);

Just a note on your practice however. For operations that return a lot of documents you are recommended to use the .AsDocumentQuery() method and then do ExecuteNextAsync while query.HasMoreResults.

You should do it that way because the CosmosDB SDK does make trips over the wire synchronously if you just use .ToList() on the IQueryable and this will be bad for your application's performance.

Here is an example from MSDN on how you can do that.

using (var queryable = client.CreateDocumentQuery<Book>(
    collectionLink,
    new FeedOptions { MaxItemCount = 10 })
    .Where(b => b.Title == "War and Peace")
    .AsDocumentQuery())
{
    while (queryable.HasMoreResults) 
    {
        foreach(Book b in await queryable.ExecuteNextAsync<Book>())
        {
            // Iterate through books
        }
    }
}

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Get All 'documents' from MongoDB 'collection'

分類Dev

How to get all documents from a collection in FaunaDB?

分類Dev

How to get all documents from a firestore collection and return them in an array list?

分類Dev

Get all documents from mongo collection using a nested list comprehension in Python

分類Dev

Get all documents from mongo collection using a nested list comprehension in Python

分類Dev

Find all documents in a collection with mongo go driver

分類Dev

Get the count of the number of documents in a Collection Mongodb

分類Dev

Updating all documents in a collection (million+) with Date object

分類Dev

What is the preferred way to add many fields to all documents in a MongoDB collection?

分類Dev

Get names of all keys in the collection and subdocuments

分類Dev

Get all in MongoDB collection using SocialCMS with Breeze

分類Dev

Get all documents of a type in mongoose but only with 1 specific item of each documents array

分類Dev

CosmosDB/DocumentDB partitioning with multiple types in same collection

分類Dev

Working with Firestore documents and collection data

分類Dev

How to get all of the collection ids from document on Firestore?

分類Dev

get 'Documents' path in Matlab

分類Dev

How to stop insertion of Duplicate documents in a mongodb collection

分類Dev

firestore: arrays vs sub collection of documents performance

分類Dev

Fast query and deletion of documents of a large collection in MongoDB

分類Dev

Apache nutch not indexing all documents to apache solr

分類Dev

Removing all documents and collections from the Firestore

分類Dev

How to filter documents in a collection when inside an array in Arangodb?

分類Dev

MongoDB: How to read all documents from all collections use expressjs?

分類Dev

How to get keys of nested mongodb documents

分類Dev

How to get matched sub documents from mongodb?

分類Dev

Swift get Documents Directory returns empty String

分類Dev

Elasticsearch: get multiple specified documents in one request?

分類Dev

Get value of an Object inside a Collection

分類Dev

Get parent collection from document

Related 関連記事

  1. 1

    Get All 'documents' from MongoDB 'collection'

  2. 2

    How to get all documents from a collection in FaunaDB?

  3. 3

    How to get all documents from a firestore collection and return them in an array list?

  4. 4

    Get all documents from mongo collection using a nested list comprehension in Python

  5. 5

    Get all documents from mongo collection using a nested list comprehension in Python

  6. 6

    Find all documents in a collection with mongo go driver

  7. 7

    Get the count of the number of documents in a Collection Mongodb

  8. 8

    Updating all documents in a collection (million+) with Date object

  9. 9

    What is the preferred way to add many fields to all documents in a MongoDB collection?

  10. 10

    Get names of all keys in the collection and subdocuments

  11. 11

    Get all in MongoDB collection using SocialCMS with Breeze

  12. 12

    Get all documents of a type in mongoose but only with 1 specific item of each documents array

  13. 13

    CosmosDB/DocumentDB partitioning with multiple types in same collection

  14. 14

    Working with Firestore documents and collection data

  15. 15

    How to get all of the collection ids from document on Firestore?

  16. 16

    get 'Documents' path in Matlab

  17. 17

    How to stop insertion of Duplicate documents in a mongodb collection

  18. 18

    firestore: arrays vs sub collection of documents performance

  19. 19

    Fast query and deletion of documents of a large collection in MongoDB

  20. 20

    Apache nutch not indexing all documents to apache solr

  21. 21

    Removing all documents and collections from the Firestore

  22. 22

    How to filter documents in a collection when inside an array in Arangodb?

  23. 23

    MongoDB: How to read all documents from all collections use expressjs?

  24. 24

    How to get keys of nested mongodb documents

  25. 25

    How to get matched sub documents from mongodb?

  26. 26

    Swift get Documents Directory returns empty String

  27. 27

    Elasticsearch: get multiple specified documents in one request?

  28. 28

    Get value of an Object inside a Collection

  29. 29

    Get parent collection from document

ホットタグ

アーカイブ