I'm creating an application that needs to query different collections for each view.
I believe that the simplest way to do this would be to assign the name of the route to a variable that corresponds to the name of the collection in the Firestore within my pinia store.
And then call that variable when querying the collection, like this.
async getNotes() {
getNotesSnapshot = onSnapshot(collection(db, 'users', userId, thisRouteName)
, (querySnapshot) => {
let notes = []
querySnapshot.forEach((doc) => {
let note = {
id: doc.id,
content: doc.data().content,
date: doc.data().date
}
notes.push(note)
})
this.notes = notes
})
}
How do I assign the current route name in thisRouteName variable?