Angularfire: Firebase.update failed: First argument contains an invalid key ($key) in path /$key. Keys must be non-empty strings and can't contain ".", "#", "$",

Created on 20 Aug 2016  路  13Comments  路  Source: angular/angularfire

code code today at 5 45 01 pm

snappyapp snappyapp today at 5 46 09 pm

  upDateMeetUp(meetup: Meetup): Observable < any > | Promise < any > | any {
    console.log(meetup.$key);
    return this.meetups.update(meetup.$key, meetup);
  }

I don't know what cause this as key and path are right.

Most helpful comment

const $key = obj.$key
delete obj.$key
update($key, object)

All 13 comments

I konw why..... I didn't remove the $key..

@jerry-i , Please can u explain by removing the $key. Thanks

delete (meetup.$key)

Do you mean you did not delete $key in meetup? WHy is this needed? I have same problem now. @jerry-i

me too :(

@jerry-i @BernardMarieOnzo I see only one reason: there is $key property in the firebase db in each item of the list. So, what should firebase do when somebody is trying to update $key prop? This can be the reason.

only because the second param will overwrite all prop but just not this $key, $key is just firebase index.

Oh I just re-read the error message:

Keys must be non-empty strings and can't contain ".", "#", "$"

I just realized that this is about keys of object which I pass as 2-nd argument =) I accidently thought that it is about key which I pass as 1st argument.

const $key = obj.$key
delete obj.$key
update($key, object)

Ye ye. I understand how to delete prop :) :+1:

I just surprised that I understood error message wrong.

const $key = obj.$key
delete obj.$key
update($key, object)

I do not understand, please help.

@johnjiea What do you not understand?

You have err in your code:

const $key = obj.$key
delete obj.$key
update($key, object); // <--- update($key, obj);

@jerry-i thanks it worked for me.

Was this page helpful?
0 / 5 - 0 ratings