Im creating a signup component in my app using Firebase as Auth method and Database. When I register a new user, a key is generated and then I save all the user info including the UID from authentication in my database. What I want to do is to use UID from authentication as my primary key instead of the key generated by Firebase.
This is my code:
component.ts
signupUser(user: User) {
this.firebaseAuth.auth
.createUserWithEmailAndPassword(user.email, user.password)
.then(value => {
console.log('Success!', value);
this.afdb.list('users').push({
firstname: user.firstname,
lastname: user.lastname,
email: user.email,
uid: value.uid
});
})
.catch(err => {
console.log('Something went wrong:',err.message);
});
}
json in Firebase
users {
-KpgNYJ0adjVyOGJiyBF {
email: [email protected]
firstname: dasdsa
lastname: dsadsads
uid: 021oxk8X6rQL6gAfC0UhZpB4vZx2
}
}
What I want
users {
021oxk8X6rQL6gAfC0UhZpB4vZx2 {
email: [email protected]
firstname: dasdsa
lastname: dsadsads
}
}
Your help is deeply appreciated as always. Thanks.
EDIT: I forgot to tell Im using AngularFire2.