我幾乎可以肯定,我的問題沒有解決方案只使用firebase,但讓我試試。 我必須得到一個特定的節點來排序它的另一個值,更好地解釋:我必須讓所有的孩子「empregado」按「數據」排序。 這是我的數據:Firebase等於一個屬性和orderBy另一個
"ponto" : {
"-KEggOdWvibrLfpptyfX" : {
"data" : "04/04/2016",
"empregado" : "-KEHl6qtSG7UkZU8Gi4t",
"entradaM" : "07:03",
"entradaT" : "12:01",
"equipe" : "-KDYYDYMqc0l0irnOGjP",
"horas" : "09:00",
"horas100" : "",
"horas50" : "",
"obra" : "-KDcuiLXj8IgVB5RalLS",
"observacao" : "tsts",
"saidaM" : "11:01",
"saidaT" : "17:00"
},
"-KEggYHd7bBkv04XSx2C" : {
"data" : "05/04/2016",
"empregado" : "-KEHl6qtSG7UkZU8Gi4t",
"entradaM" : "07:01",
"entradaT" : "12:02",
"equipe" : "-KDYYDYMqc0l0irnOGjP",
"horas" : "09:00",
"horas100" : "",
"horas50" : "01:00",
"obra" : "-KDcuiLXj8IgVB5RalLS",
"observacao" : "tsts",
"saidaM" : "11:01",
"saidaT" : "18:00"
},...more data with repeated key "empregado" and not repeated too
所以,我所做的:
ref.child("ponto").orderByChild("empregado").equalTo("-KEHl6qtSG7UkZU8Gi4t").on("child_added", function(snapshot) {
ponto = snapshot.val();});
和完美的我得到的數據,但我需要孩子來訂購吧「數據」,所以我想這可能是通過這樣的事情來解決:
ref.child("ponto").orderByChild("data").orderByChild("empregado").equalTo("-KEHl6qtSG7UkZU8Gi4t").on("child_added", function(snapshot) {
ponto = snapshot.val();});
但它說我不能使用兩次「orderByChild」 想法? 從此開始感謝。
查看http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase –