如何编写使用Angular中的firestore从一个引用中获取一份文档的价值?

问题描述

我该如何使用Angular中的firestore编写从一个引用中获取一份文档的价值?

根中有两个集合,一个集合通过id(数字ID(参考))通过引用连接。

users (collection)
 |-- userid (document)
       |-- name
       |-- digitalID (reference)

digitalContents (collection)
 |-- digitalID (document)
       |-- name
       |-- price

即使执行以下操作,我也无法取值。

constructor(public auth: AuthService,private afs: AngularFirestore) { }

  ngOnInit(): void {
    const user = this.auth.currentUser;

    this.selectedContentsPrice = this.afs.collection<User>(`users/${user.userid}/digitalID`).valueChanges().subscribe(data => data.price);
    console.log(this.selectedContentsPrice)

如何从一个引用获取连接的集合的值? 例如)digitalContents的价格

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)