this.afs.collection<User>(`users`).valueChanges()
.map(domains => {
return this.convertToArray(domains).filter(domain => {
return domain;
});
});
域名返回:
{creationDate:1516798886902
displayName:"mohamedabo8414"
domain:"@mohamedabo8414"
followersCount:0
followingCount:0}
我想为这个用户获取uid。我该怎么办?
答案 0 :(得分:1)
.valueChanges()
不会发出密钥。请改用.snapshotChanges()
。尝试
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;
});
});
答案 1 :(得分:0)
根据您的评论
我用这样的uid命名域对象&#34; VEtdoqabg4bkanB6Ky9CI3dvzOu1&#34;:{creationDate:1516798886902 displayName:&#34; mohamedabo8414&#34;域:&#34; @ mohamedabo8414&#34; followersCount:0 followingCount:0}
如果你想获取uid VEtdoqabg4bkanB6Ky9CI3dvzOu1
,那么根据official documentation,在您的情况下domain.id()
应该会获得上述内容。