So I'm aware you can read through your own nested collections while having the following:
db.collection('usuarios').doc(user.uid).collection('pedidos').doc()
but that would only read all the "pedidos" of that current user
I'm making some kind of "admin" so I need to see ALL the "pedidos" of ALL users and if I remove the values of .doc(user.uid)
it will not go through all users it will just not do anything
ej: db.collection("usuarios").doc().collection("estudiantes")
<- This didn't work
So I'm looking for a way to read all users nested collection
I can read all users without issues is as simple as db.collection("usuarios")
but I need to access their nested collection and I can't do something like db.collection("usuarios").collection("pedidos")
that will give me an error. Any help is welcome
update based on suggestion
useEffect(() => {
const usuariosRef = db.collectionGroup('pedidos').get()
usuariosRef.onSnapshot(snapshot => {
const tempData = [];
snapshot.forEach((doc) => {
const data = doc.data();
tempData.push(data);
});
setEstudiantes(tempData);
})
}, [user]);