vuefire
vuefire copied to clipboard
Firestore get once
This is a feature request for a convenient way of assigning the result of query.get()
to a property in the data model.
Similar to the firestore
option or the the vm.$bind
method, but without subscribing for updates.
If I understand correctly, currently one has write the following achieve the described outcome?
{
async created () {
const querySnapshot = db.collection('mydocs').get()
this.mydocs = querySnapshot.docs.map(documentSnapshot =>
Object.defineProperty(documentSnapshot.data(), 'id', {
value: documentSnapshot.id,
enumerable: false,
})
)
}
}
Right now this should be possible by awaiting a bind and then unbinding it. For Firestore, this benefits from fetching references. Maybe this could be added as a standalone function that is re exported by both vuefire and vuexfire
Any updates on this?
there is an option once
now:
useDocument(.., { once: true })
This option is forced to true during SSR