Angular:
2.0.1
Firebase:
2.4.30
AngularFire:
2.0.0-beta-4
Currently I am using:
this.af.database.list('users').push(user);
How can I make the key of the object that is submitted be custom. So I want to be able to set the node of this object to the same uid of the registered user. I have access to this Id I just need to be able to know how to make the custom user objects node not be the auto generated id when pushing.
Thanks
@StevenAderson Lists will always auto-generate, which is good thing! If you need to specify your own key in a list, then a use object(key: string).
this.af.database.object(`list/myCustomKey`).update({ age: 101 });
Thanks it works great!
Yes, but what if I need a generated key in order to use it later in other collection, but for this particular collection, I need to replace the key and keep the content? How can I update only the key?
@coltaemanuela You cannot update keys. You can create a new key with the same content and delete the other one however.
Is this possible with firestore?
@davideast ,
This solution this.af.database.object(list/myCustomKey).set(values) is not working for me. If I want to insert a new value, first time it works, but second time with same myCustomKey if I try its updating the previous value, instead rejecting.
Set is destructive. Look here https://github.com/angular/angularfire2/blob/master/docs/rtdb/objects.md
Most helpful comment
@StevenAderson Lists will always auto-generate, which is good thing! If you need to specify your own key in a list, then a use
object(key: string).