【发布时间】:2017-10-18 07:57:25
【问题描述】:
我正在尝试使用 FireStore 查询 AngularFire2 中的子集合,但没有成功。已搜索但没有找到合适的解决方案。
ngOnInit() {
// this does work
this.africaCollection = this.afs.collection('Country', ref => ref
.where('code', '==', 'za'));
this.countriesAfrica = this.africaCollection.valueChanges();
// this does not work
this.townCollection = this.afs.collection('Country').doc('za')
.collection('Towns');
this.towns = this.townCollection.valueChanges();
{
我的 HTML 如下所示:
<div>
<table>
<tr *ngFor="let town of towns | async">
<td>{{ town.name }}</td>
</tr>
</table>
</div>
我是这方面的新手。
【问题讨论】:
-
您可以使用 stackblitz.com 重新创建问题吗?我可以通过一个示例提供更多帮助(我是 AngularFire 的作者)
-
嗨,David - 使用 stackblitz 有困难,但我已将我的尝试放在 github github.com/JacquesSchalkwyk/Firestore-Qry。我希望这将有所帮助。目前我的数据库有默认规则,每个人都可以读写。结构是 Country-Towns-Listings
-
当我将规则设置为 :-service cloud.firestore { match /databases/{database}/documents { match /Country/{country}{ allow read, write; } } }
标签: angularfire2 google-cloud-firestore