【发布时间】:2017-05-14 01:50:15
【问题描述】:
我有一个结构如下的 firebase 数据库:
-users
-[userID from the account]
-[interval key generated automatically with push]
-start: timestamp
-end: timestamp
-color: black
-[interval key]
-start: timestamp
-end: timestamp
-color: red
-[interval key]
-start: timestamp
-end: timestamp
-color: green
-[userID2 from the account]
-[interval key]
-start: timestamp
-end: timestamp
-color: black
-[interval key]
-start: timestamp
-end: timestamp
-color: white
-[interval key]
-start: timestamp
-end: timestamp
-color: red
使用 android 我不明白如何进行一些组合查询。
如果我有:
long start = 1494637200000;
long end = 1494640800000;
和:
DatabaseReference userRef = dbRef.child("users").child(uid);
如果我不能使用 orderByChild() 超过 1 次:
1)如何从数据库中获取与start 和end 重叠的所有区间?
Sql:
select *
from [userID]
where start + " < " + 1494640800000 + " AND " + end + " > " + 1494637200000
2)我如何从数据库中获取与start 和end 重叠的所有间隔,但只能使用颜色“black”?
Sql:
select *
from [userID]
where start + " < " + 1494640800000 + " AND " + end + " > " + 1494637200000 AND color = "black"
(我接受不同语言的答案,只是让它易于理解)
【问题讨论】:
标签: android firebase firebase-realtime-database nosql