question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add method for getting list of documents (as objects) from a collection

See original GitHub issue

Currently, if you want to get a list of all documents (as JSON objects) from a collection, you have to

  1. Call getDocumentIds(pathToCollection, email, key, projectId) to get the IDs for the collection
  2. Loop through these IDs and combine the pathToCollection with the ID to make the document path.
  3. Call getDocumentFields(path, email, key, projectId) for each document ID / path to get a JSON object for that document.

This should be combined into a single method.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
thesandlordcommented, Feb 3, 2018

Hey @grahamearley, we recently did a Hackathon and added query support to this library. I’ll hopefully send a PR with this functionality soon, and it will allow you to get multiple documents from a collection easily. This has the big advantage of doing a single URLFetch instead of O(n) URLFetches.

Right now, I’m thinking the method call will look very much like the “get” method, but will have a param called “query” instead of “path” that will be a Firestore StructuredQuery.

I’m thinking it will look something like this:

query(query, email, key, projectId) {
  query_(query, email, key, projectId);
}

getAllDocuments(path, email, key, projectId) {
  var query = {
    from: [{collectionId: path}]
  };
  query_(query, email, key, projectId);
}

query_(query, email, key, projectId) {
  // Code to Query and Return Documents
}

0reactions
grahamearleycommented, May 31, 2018

Covered by #28 and released in v16!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add List of Object to Firestore? - Stack Overflow
What you can actually do is create a CustomStep and a CustomSteps Collection. Inside your CustomSteps Document you can create an array of ......
Read more >
Get data with Cloud Firestore - Firebase
Get all documents in a collection; Get multiple documents from a collection group. List ... the text explaining the samples refers to the...
Read more >
db.collection.insert() — MongoDB Manual
If the collection does not exist, then the insert() method will create the collection. _id Field. If the document does not specify an...
Read more >
Adding data | Firestore - Google Cloud
Set the data of a document within a collection, explicitly specifying a document ... the text explaining the samples refers to the Web...
Read more >
Collection Methods | Documents | Data Model & Concepts
Looks up the documents in the specified collection using the array of keys provided. All documents for which a matching key was specified...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found