Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
Firestore : get all files ( only specify ids)

I need to retrieve all file with specify id

my firestore ( structure )

users/user1/img1 -> [ fileId = img1  , file = img1.jpg ]
users/user2/img2 -> [ fileId = img2  , file = img2.jpg ]
users/user3/img3 -> [ fileId = img3  , file = img3.jpg ]

I find in the document , the 'getAll' methods ( https://googleapis.dev/nodejs/firestore/latest/Firestore_.html#getAll )

but with their example, it don't work.

My code

import storage  from "@react-native-firebase/storage";

let docRef1 = storage().doc('/users/user1/img1');
let docRef2 = storage().doc('/users/user2/img2');
return new Promise((resolve, reject) => {
    // Now we get the references of these images
    storage().getAll(docRef1, docRef2).then(docs => {
        resolve()
    }).catch(function(error) {
        // Handle any errors
        console.log('error', error)
        reject()
    });

My error:

TypeError: (0, _storage.default)().doc is not a function. (In '(0, _storage.default)().doc('/products/3799569030005-1.jpg')', '(0, _storage.default)().doc' is undefined)

Update 1: after the post of Frank van Puffelen I modify my code to test with an id

import firestore from "@react-native-firebase/firestore";
let docRef1 = firestore().collection('users').doc('user1/img1');
let docRef2 = firestore().doc('/users/user1/img1');
// use with docRef1  or docRef2
docRef2.get().then(docSnapshots => {
        console.log('AA1 docSnapshots data', docSnapshots.data())
    }).catch(err => {
        console.log('AA2 err', err)
    })
// error for the docRef1 and docref2 =>  Error: firebase.firestore().doc(*) 'documentPath' must point to a document.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

By calling storage() you're using the API for Firebase Storage, which accesses files in Cloud Storage (storing files). But then you say you want to access documents in Cloud Firestore, which is a noSQL document database.

While both Firestore and Storage can be access through Firebase SDKs, they are completely separate and the API for one has nothing to do with the other. If you want to access Firestore, use firebase.firestore()... (or just firestore() on react-native-firebase).


The getAll() method you linked to exists in the Node.js SDK for Firestore. It does not exist in the JavaScript/Web SDK nor in the react-native-firebase wrapper. In those SDKs, you will have to call get on each individual DocumentReference object, or you can use an in query on FieldPath.documentId().

The first approach (as that is closest to the code in your question):

let docRef1 = firestore().doc('/users/user1/img1');
let docRef2 = firestore().doc('/users/user2/img2');
Promise.all([docRef1.get(), docRef2.get()])
  .then((docSnapshots) => {
    console.log(docSnapshots[0].data(), docSnapshots[1].data());
  });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!