[英]Firebase orderByChild with path and equalTo boolean doesn't return anything
Alright, so I have my data structure in the realtime database looking something like this: 好吧,所以我的实时数据库中的数据结构如下所示:
and when I run a query like this: 当我运行这样的查询时:
database.ref('access_lists').orderByChild('95577307/read').equalTo(true)
I receive absolutely nothing from the query. 我从查询中什么也没收到。 As far as I can tell this should work, but I'm kind of at a loss at why it doesn't. 据我所知,这应该行得通,但是我有点茫然为什么不行。
You have a key inside another key that's why you get no value, if the numbers 95577307, ...
have a purpose but don't need to be a value use it as a key by changing the way you are structuring your data: 您在另一个键中有一个键,这就是为什么没有值的原因,如果数字95577307, ...
有目的,但不需要成为值,则可以通过更改构造数据的方式将其用作键:
access_lists: {
95577307: {
name: 'FelixJar1'
read: true
write: true
}
}
This would also help you sort/filter users that have read/write equalTo(true). 这也将帮助您对具有读/写equalTo(true)的用户进行排序/过滤。 https://firebase.google.com/docs/database/web/structure-data#flatten_data_structures https://firebase.google.com/docs/database/web/structure-data#flatten_data_structures
========================================== ==========================================
This is how Firebase does it: 这是Firebase的工作方式:
"posts": {
"ts-functions": {
"metrics": { <===== it's the same key name
"views" : 1200000,
"likes" : 251000,
"shares": 1200,
},
"title" : "Why you should use TypeScript for writing Cloud Functions",
"author": "Doug",
},
"android-arch-3": {
"metrics": { <===== it's the same key name
"views" : 900000,
"likes" : 117000,
"shares": 144,
},
"title" : "Using Android Architecture Components with Firebase Realtime Database (Part 3)",
"author": "Doug",
}
},
Because they have a key name metrics
they can index it inside firebase rules and also be able to filter/sort/order values example: metrics/views
由于它们具有关键字名称metrics
因此可以在Firebase规则中为其编制索引,还可以过滤/排序/订购值,例如: metrics/views
You on the other hand have 995055869, 950336178....
另一方面995055869, 950336178....
您有995055869, 950336178....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.