Vuefire: Many problems regarding to references.

Created on 10 May 2017  路  2Comments  路  Source: vuejs/vuefire

Actually, this.$firebaseRefs is not populated to child components so I have to access it through vue-router on a computed property:

// Features.vue (child of App.vue)
computed: {
    $firebaseRefs () {
        return this.$router.app.$firebaseRefs;
    }
}

and then my update() method throws an error:

Firebase.update failed: First argument contains an invalid key (.key) in path /.key. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"
update () {
        this.$firebaseRefs.features.child(this.feature['.key']).update(this.feature);
    }

I tried using this reference directly, but it says child is not a function

firebase: function () {
    return {
        features: db.ref('features')
    };
}

this won't work: this.$router.app.features.child(feature['.key']).update(feature), child is not a function.

question

All 2 comments

You're talking about many different things at the same time

  1. $firebaseRefs are local to the component as you can use the same keys in different components
  2. .key is added to the data for convenience, you cannot include it in a Firebase update. so you can:
const update = Object.assign({}, item)
delete item['.key']
  1. That is related to Firebase. Make sure you're calling child on a ref on Reference (https://firebase.google.com/docs/reference/js/firebase.database.Reference#child) and not on a Query (https://firebase.google.com/docs/reference/js/firebase.database.Query). If you have a query you can access the Reference with .ref

I'll add a note on the Readme, because right now it's missleading

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mkharibalaji picture mkharibalaji  路  3Comments

amesas picture amesas  路  5Comments

franciscolourenco picture franciscolourenco  路  7Comments

weavermedia picture weavermedia  路  4Comments

calirails picture calirails  路  5Comments