小编Jos*_*tas的帖子

在 Firestore 中获取文档名称

当我从一个集合中获取多个文档时,结果只是一个包含每个文档数据的数组。

firestore.collection("categories").valueChanges().subscribe(data => {
    console.log(data);
    // result will be: [{…}, {…}, {…}]
};
Run Code Online (Sandbox Code Playgroud)

如何获取每个文档的名称?

理想的结果如下所示:

{"docname1": {…}, "docname2": {…}, "docname3": {…}}
Run Code Online (Sandbox Code Playgroud)

firebase angularfire2 google-cloud-firestore

7
推荐指数
2
解决办法
2万
查看次数

如何在Firestore中查询DocumentReference

我有一个条形码的集合,并在每个文件中我有一个字段与酒保的参考.

说明性的图像


我正试图在doc引用的位置.

像这样的东西:

orders = this.database.collection("orders",
    (ref) => ref.where("barman.path", "==", "barmen/" + this.auth.auth.currentUser.uid),
);
return orders.valueChanges();
Run Code Online (Sandbox Code Playgroud)

barman.path 因为当我得到一个带有字段引用的文档时,这是获取引用路径的方法.

我已经尝试过只使用barman代替barman.path.

我已经尝试用docref(firestore.googleapis.com/pro...)的完整"路径"来制作.

有任何想法吗?

只放入id而不是完整的引用会使系统的其他部分变得困难.

javascript firebase angularfire2 angular google-cloud-firestore

6
推荐指数
1
解决办法
360
查看次数