Firebase Android :如何获取特定子项中的列表



我正在尝试检索特定子项的内部列表。请参考以下结构。

如果我想检索"收件人"的"servicesArrayList",其中"billNo"是"135",我应该写什么查询,以便我可以将该查询传递给FirebaseRecyclerAdapter (firebase -ui(

FirebaseRecyclerAdapter 适用于特定收件人的 servicesArrayList。

    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    String uid = user.getUid();
    Query query = FirebaseDatabase.getInstance()
            .getReference(RECIPIENT_NODE)
            .child(uid)
            .child("servicesArrayList")
            .orderByChild ?


recipient // parent Node
 2R1Q8qKEPHXFU1OiMq5TyxHBaZa2 // uId
   -KgJhMAWADwownv5tck6  // push Id
   -KgJhMAWADwownv5tck6
   -KgJoD77HQK-yACD_EuB
   -KgJoRXVUP_-Z0gLhIWy
   -KgJob82t47PvTjfTtig
   -KgK-N_Av_2kmmQS0Ulx
   -KgNu-fVWwFDLnRENj_b // Recipient Data
        billNo: 135
        billingMonth: "July 2017"
        childGender: "Ms."
        childName: "xyz"
        date: "29/03/2017"
        fineAmount: 0
        paymentStatus: "UNPAID"
        pushId: "-KgNu-fVWwFDLnRENj_b"
        receiptUrl:"https://firebasestorage.googleapis.com/v0/b/ngf..."
        recipientEmail: "abc@gmail.com"
        recipientName: "Abc C."
        servicesArrayList
                 -0
                    -amount: 1000
                    -charges: "1000"
                    -noOfSessions: 1
                    -serviceType: "Speech And Language Assessment"
        total: 1000
        vat: 0

如果你把 uid 和推送 id 剪掉,那么这应该可以做到:

Query query = FirebaseDatabase.getInstance().getReference(RECIPIENT_NODE)
    .​child(uid).child(pus‌​hId).child("services‌​ArrayList");

希望这有帮助

试试这个:

     Query query = FirebaseDatabase.getInstance()
            .getReference(RECIPIENT_NODE)
            .child(uid).orderByChild("billNo").equalTo(135);
query.addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
      Query query1= dataSnapshot.getRef().child("servicesArrayList");
       //pass this query to adapter of firebaseRecyclerAdapter      
     FirebaseRecyclerAdapter  adapter = new FirebaseRecyclerAdapter<>(,,,query1){} 
    }
    @Override
    public void onCancelled(DatabaseError databaseError) {
        // ...
    }
});

相关内容

  • 没有找到相关文章

最新更新