【问题标题】:Firebase - Get parent of child which value is unknownFirebase - 获取值未知的孩子的父母
【发布时间】:2018-07-23 03:53:49
【问题描述】:

我需要得到孩子(我需要代码中的孩子)但我不知道如何访问它,如果我知道保存为他孩子的父母的 ID。我还需要检查小组中的每个人并得到他们的我需要的孩子

【问题讨论】:

    标签: javascript json firebase react-native firebase-realtime-database


    【解决方案1】:

    你可以这样做:

     DatabaseReference dbRef = FirebaseDatabase.getInstance().getChild("ID I know").getChild("request");
     dbRef.addListenerForSingleValueEvent(
                    new ValueEventListener() {
                        @Override
                        public void onDataChange(DataSnapshot dataSnapshot) {
                            // Here you will iterate over all the values whose ID you wont know
                            Map<String, Object> values = dataSnapshot.getValue();
                            // Iterate over the values and for each value check if it has the child you need in it
                        }
    
                        @Override
                        public void onCancelled(DatabaseError databaseError) {
                            // on error
                        }
                    });
    

    【讨论】:

    • 嗯,这只是路径中的另一个对象。整天工作让我很生气:D。无论如何谢谢你
    猜你喜欢
    • 2021-11-09
    • 2013-04-10
    • 1970-01-01
    • 2015-08-30
    • 2013-06-04
    • 2018-01-29
    • 1970-01-01
    • 1970-01-01
    • 2020-11-14
    相关资源
    最近更新 更多