Home > Mobile >  Upgrading firebase v8 to v9
Upgrading firebase v8 to v9

Time:07-05

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)
  • Related