Skip to content

Map data on $bind #777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Masterxhen opened this issue Jun 5, 2020 · 2 comments
Closed

Map data on $bind #777

Masterxhen opened this issue Jun 5, 2020 · 2 comments

Comments

@Masterxhen
Copy link

Is it possible to map data during binding like in sqls that gets a specific collumn/property of a firestore/realtime database document? Like the array.prototype.map on querying

this.$bind('documents', db.collection('documents').map(data => { return {name: data.name, age: data.age})

@fvanwijk
Copy link

fvanwijk commented Jun 5, 2020

Use a computed property to get derived data that updates automatically.

computed: {
  mappedDocuments() {
    // Only get name and age keys
    return this.documents.map(({ name, age }) => ({ name, age }));
  }
}

In this particular case of a field mask you could use a DataConverter, but I think it is only supported when you do a one-time query.

@posva
Copy link
Member

posva commented Jun 13, 2020

Use a computed property for the moment. See #608

@posva posva closed this as completed Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants