Find if child inside child data is exist or not Android Firebase

前端 未结 4 796
遥遥无期
遥遥无期 2020-12-12 08:08

This may be duplicate Question but i have tries alot but i didnt get my result, Here is my firebase structure

Updated

I need to fin

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 08:23

    To solve this, I recommend you to change your database structure a little bit. Because there is no way to use in a query dynamic values, or wildcards, you database schema should look like this:

    Expense_monts
       |
       --- November_2018
              |
              --- -LQ ... Gb
              |     |
              |     --- expensesName: "gross"
              |     |
              |     --- total: 66
              |     |
              |     --- day: "Monday"
              |
              --- -LQ ... LO
                    |
                    --- expensesName: "oil"
                    |
                    --- total: 33
                    |
                    --- day: "Tuesday"
    

    As you can see, there is no need to use that extra child (3, 4 and so on). In this case, a query that looks like this:

    expensesaddref = databaseReference.child(username).child("Expense_Month").child(monthyr);
    expensesaddref.orderByChild("expensesName").equalTo("oil")
        .addListenerForSingleValueEvent(/* ... */);
    

    Will work perfectly fine.

提交回复
热议问题