当前,我正在使用带Firebase实时数据库的应用程序。在数据库中,它们是客户和工作对象。我当前数据的结构如下所示。我想按客户的要求进行过滤。我必须在firebase中执行哪种查询?
+--customers
|
+-- customerKey1
| |
| +-- <customerData1> ..
|
+-- customerKey2
|
+-- <customerData2>..
+--works
|
+-- workKey1
| |
| +-- customerKey : customerKey2 // this work belongs to customer2
| |
| +-- <the rest of work1 data
|
+-- workKey2
| |
| +-- customerKey : customerKey2 // this work belongs to customer2
| |
| +-- <the rest of work2 data
|
+-- workKey3
| |
| +-- customerKey : customerKey1 // this work belongs to customer1
| |
| +-- <the rest of work3 data
|
+-- workKey4
|
+-- customerKey : customerKey1 // this work belongs to customer1
|
+-- <the rest of work4 data
答案 0 :(得分:0)
要获取特定客户的works
节点,请使用Firebase查询:
firebase.database().ref('works').orderBy('customerKey').equalTo('customerKey2')
有关更多信息,请参见Firebase documentation on sorting and filtering lists of data。