使用$firebaseArray equalTo()数组值进行查询的最佳方法是什么?
考虑到我已经像这样构建了我的数据库使用$firebaseArray equalTo()数组值进行查询的最佳方法是什么?,firebase,angularfire,firebase-realtime-database,Firebase,Angularfire,Firebase Realtime Database,考虑到我已经像这样构建了我的数据库 users:{ user1: { username: "johndoe" }, user2: { username: "foobar" } } user-timeline: { user1: { post1: true, post2: true, post3: true }, user2: { post3: true } } posts:
users:{
user1: {
username: "johndoe"
},
user2: {
username: "foobar"
}
}
user-timeline: {
user1: {
post1: true,
post2: true,
post3: true
},
user2: {
post3: true
}
}
posts: {
post1:{
caption: "caption 1",
author: "user1"
},
post2:{
caption: "caption 2",
author: "user1"
},
post3:{
caption: "caption 3",
author: "user2"
}
}
如何获得所有帖子数据(包括与user1的时间线关联的每篇帖子的作者数据)的最佳方法?由于user1在其时间轴中关联了post1、post2和post3
,因此查询将获取如下数据:
[
{
$id: post1,
caption: "caption 1",
author:{
$id: "user1", username: "johndoe"
}
},
{
$id: post2,
caption: "caption 2",
author:{
$id: "user1", username: "johndoe"
}
},
{
$id: post3,
caption: "caption 3",
author:{
$id: "user2", username: "foobar"
}
}
]
$firebaseArray($firebaseRef.child('posts').equalTo(['post1','post2','post3']));
我知道,目前firebase不支持从多个值进行类似的查询:
[
{
$id: post1,
caption: "caption 1",
author:{
$id: "user1", username: "johndoe"
}
},
{
$id: post2,
caption: "caption 2",
author:{
$id: "user1", username: "johndoe"
}
},
{
$id: post3,
caption: "caption 3",
author:{
$id: "user2", username: "foobar"
}
}
]
$firebaseArray($firebaseRef.child('posts').equalTo(['post1','post2','post3']));
是否有人能解释一下使用AngularFire实现它的最佳方法,并在每次添加或删除新帖子时保持数据同步?两年后,这仍然是不可能的。。。。