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.