私は次のように構造化さfirebaseデータベース持っている:私はいくつかの複合クエリーを作成する方法を理解していないアンドロイドを使用して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
を。
私が持っている場合:
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)どのように私は、「black
」だけの色と、データベースからstart
とend
と重複しているすべての間隔を得ることができますか?
SQL:The Firebase Database For SQL Developers:
select * from [userID] where start + " < " + 1494640800000 + " AND " + end + " > " + 1494637200000 AND color = "black"
(私は、異なる言語で回答を受け入れ、ちょうどそれが理解できるよう)
私は以前このチュートリアルを見てきましたが、2-3文字の子供たちを照会する唯一の方法は、特殊文字で区切られた1つの値で組み合わせることでした。それは唯一の方法ですか? – 4bottiglie
はい、そうです。これはFirebaseの一般的なプラクティスです。 –
ある期間が経過した後、他の3つのパラメータでクエリを実行したい場合は、すべての間隔を新しい値で更新する必要がありますか?あなたの意見では、すべてのクライアントでそれらを1つずつフィルタリングする方がコストがかかりますか? – 4bottiglie