Reputation: 1137
this.afs.collection<User>(`users`).valueChanges()
.map(domains => {
return this.convertToArray(domains).filter(domain => {
return domain;
});
});
Domain returns:
{creationDate:1516798886902
displayName:"mohamedabo8414"
domain:"@mohamedabo8414"
followersCount:0
followingCount:0}
I want to get uid for this user. How can I do it?
Upvotes: 1
Views: 1929
Reputation: 6900
.valueChanges()
doesn't emit the keys with it. use .snapshotChanges()
instead. Try
this.afs.collection<User>(`users`).snapshotChanges().map(actions=>{
return actions.map(b=>{
const data = b.payload.doc.data();
const id = b.payload.doc.id;
return {uid:id,...data}
})
}).map(domains => {
return this.convertToArray(domains).filter(domain => {
return domain;
});
});
Upvotes: 2
Reputation: 355
Based on your comment
I named domain object with uid like this "VEtdoqabg4bkanB6Ky9CI3dvzOu1": { creationDate:1516798886902 displayName:"mohamedabo8414" domain:"@mohamedabo8414" followersCount:0 followingCount:0}
If you want to fetch the uid VEtdoqabg4bkanB6Ky9CI3dvzOu1
then according to the official documentation, in your case domain.id()
should get you the above uid.
Upvotes: 0