Skip to content

Allow customizing how the data is stored (id, adding properties, transforming them) #240

Closed
@posva

Description

@posva

Right now the data is created using https://github.com/vuejs/vuefire/blob/master/packages/%40posva/vuefire-core/src/utils.js#L9-L14

Looking at Firestore extensions like Geofirestore that add a distance property that is lost upon binding with Vuefire. This would allow adding the distance to the object bound.
It would also allow customizing the key/id attribute although I still feel that having a simple string field is nice.

API

The api would be the same for firebase and firestore

Vue.use(firestorePlugin, {
  // override createsnapshot
  createSnapshot (doc) {
	return Object.defineProperty(doc.data(), 'id', {
      value: doc.id
	})
  }
})
this.$bind('item', { createSnapshot })
bindFirestoreRef('item', { createSnapshot })

It will also be nice to provide a way to override globally for vuexfire

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions