Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda