Closed asankulov closed 5 years ago
Hi @asankulov.
When you define your source in the firestore function, vue-firestore
automatically binds this source as an array if it is a collection, otherwise vue-firestore
will bind it as an object.
May you explain about binding as object or give some example?
Hello @asankulov.
Originally Vue-firestore binds collections as an array of documents (Array of objects). [{obj1}, {obj2}, {obj3}]
and binds documnets as a single object.
Example:
....
firestore() {
return {
cars: firestore.collection('cars'), // Array of documents.
ford: firesotre.doc('cars/ford') // Single document.
}
}
....
Results:
console.log(this.cars)
// [{.key: "mercedess", model: "2015"}, {.key: 'ADF783Sf1lz40zvVv1d2', model: "2001"}, ......]
console.log(this.ford)
// {.key: "ford", model: "2014"}
And bear in mind that each record we get form the firestore will be indecated with .key
property.
Thank you :)
Ok but I meant not single document I mean full collection. Like {'dx3fe4cdef54xsz970': {model: 'BMW'}, 'cr773qcr366crf244fc': {model: 'Nissan'} }
yeah, I see, this will be a decent new feature to be implemented, Thanks a lot!
@asankulov, binding collections as an object is available with the new release 0.3.1
.
Thanks.
Is it possible to make selectable type of collection like array or object. Example from VueFire is below: