I am learning angularfire2 in Ionic2
const newUser = this._db.list('/users');
setTimeout(() => {
newUser.push(this.userInfo)
.then((data) => console.log(data))
},3000)
I want to know if there is any way I can set my custom key when pushing new data. I tried various suggestion given on internet to update the key after insert, but no success.
Rather than .push
, I tried .set
const userList = this._angualrFireDB.list('/users');
userList.set(this.userAuthData.uid,
{
name: 'Ashwin',
age: 38,
dob: '10/11/1978',
uid: this.userAuthData.uid
});
This works, and I am getting my uid as my new key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With