vuefire icon indicating copy to clipboard operation
vuefire copied to clipboard

Firestore get once

Open franciscolourenco opened this issue 5 years ago • 2 comments

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,
			})
		)

	}
}

franciscolourenco avatar May 20 '19 16:05 franciscolourenco

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

posva avatar Dec 30 '19 22:12 posva

Any updates on this?

dimavolo avatar Aug 17 '20 13:08 dimavolo

there is an option once now:

useDocument(.., { once: true })

This option is forced to true during SSR

posva avatar Dec 05 '22 11:12 posva