【发布时间】:2019-11-12 12:59:33
【问题描述】:
// 我现在的数据库结构
rcv : {
visible: 'all',
ids: [
[0] : userId,
[1] : user2Id ]
}
这就是我查询数据的方式。
//service.ts
getAlbumByUserId(userId) {
return this.afs.collection('albums', ref => ref.where('rcv.visible', '==', 'all').where('rcv.ids', 'array-contains', userId)).valueChanges();
}
//component.ts
this.service.getAlbumByUserId(this.userId);
但我想设置这样的结构,但我不知道如何在 firebase 中查询嵌套对象
//数据库结构
rcv : {
visible: 'all',
ids: {
userId: {
id: userId
}
user2Id: {
id: user2Id
}
}
}
【问题讨论】:
标签: javascript angular firebase google-cloud-firestore