gdg-tangier / vue-firestore

:cloud: Cloud Firestore binding in realtime with Vuejs
MIT License
235 stars 28 forks source link

Adding the key for the first time #40

Open hsouiri97 opened 5 years ago

hsouiri97 commented 5 years ago

when you add a document for the first time you can not see the id in the firestore console, only you can see it when you update the doc.

amranidev commented 5 years ago

HI @hsouiri97 can you provide an example?

hsouiri97 commented 5 years ago

@amranidev when we call this function this.$firestore.persons.add() for the first time we can save the object in firestore however we can not see the id or ".key" value in firestore console, but if we looped trough the list of objects in our application and console log them we can see that they have and id value, so then if we call this.$firestore.persons.doc(person['.key']).update() we can see that the ".key" value has been added to firestore console.

1. Adding the object with this.$firestore.persons.add()

issue1

2. Looping through the objects and console log them so we can see the id value:

issue2

3. Calling the this.$firestore.persons.doc(person['.key']).update() function and checking the firestore console to see that the id has been added

issue3

Note that I used this Vue.use(VueFirestore, { key: 'id', enumerable: true }) to customize the name of the .key property.