Firebase - > Firestore
I have this code which I want to convert it into v9 but can't seem to figure out the correct syntax.
db.collection('chats').doc(router.query.id).collection('messages').orderBy('timestamp', 'asc')
CodePudding user response:
It's something like that:
const ref = collection(db, `chats/${router.query.id}/messages`)
const q = query(ref, order('timestamp', 'asc'))
const snapshot = await getDocs(q)
if(snapshot.exits()) console.log(snapshot.docs)