您好我刚刚使用firebase和AngularFire,并且有关于数据库结构和查询的最佳实践的基本问题。
我有一个带有用户登录的应用程序,每个用户都可以创建和存储报告,因此我正在考虑如何在firebase中构建数据结构的两种方法:
首先:
{
"reports" : {
"userid_1" : {
"reportid_1" : {
"reportTitle" : "some title",
"reportMsg" : "some text"
},
"reportid_2" : {
"reportTitle" : "some title",
"reportMsg" : "some text"
},
"reportid_3" : {
"reportTitle" : "some title",
"reportMsg" : "some text"
}
},
"userid_2" : {
"reportid_1" : {
"reportTitle" : "some title",
"reportMsg" : "some text"
},
"reportid_2" : {
"reportTitle" : "some title",
"reportMsg" : "some text"
},
"reportid_3" : {
"reportTitle" : "some title",
"reportMsg" : "some text"
}
}
}
}
然后我可以这样查询:
var ref_reports = new Firebase("https://xxxxx.firebaseio.com/reports/"+userid+"/");
第二
{
"reports": {
"report_id_1": {
"userid": "userid_1",
"reportdata": {
"reportTitle": "some title",
"reportMsg": "some text"
}
},
"report_id_2": {
"userid": "userid_2",
"reportdata": {
"reportTitle": "some title",
"reportMsg": "some text"
}
},
"report_id_3": {
"userid": "userid_1",
"reportdata": {
"reportTitle": "some title",
"reportMsg": "some text"
}
}
}
}
然后通过userid进行查询和过滤数据:
var ref_reports = new Firebase("https://xxxxx.firebaseio.com/reports/");
那么过滤收到的firebase数组是否更好?或者更好地使用referenz过滤数据?
由于