vue-firestore icon indicating copy to clipboard operation
vue-firestore copied to clipboard

Adding the key for the first time

Open hsouiri97 opened this issue 5 years ago • 2 comments

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.

hsouiri97 avatar Aug 21 '19 01:08 hsouiri97

HI @hsouiri97 can you provide an example?

amranidev avatar Aug 25 '19 22:08 amranidev

@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.

hsouiri97 avatar Aug 29 '19 19:08 hsouiri97