如何比较Firebase中的UID和另一个子键? [英] How to compare UID and another child key in Firebase?
问题描述
我想用Android中的相同键连接当前用户ID,但是在另一个子节点中,我从过去的两天开始搜索,但是找不到任何解决方案,我只能获取uid,而无法获取其他解决方案我想要比较以获取数据的ID.
I want to connect the current user id with the same key in Android, but in another child node, I am searching from tow days, but cant find any solution, I can only get uid, but can't get the other id which I want to compare for retrieving data.
有人可以帮助我如何找到在另一个字段中实际上是uid的子项吗?谢谢.
Can any one help me how to find the child key which is actually uid in another field? Thanks.
推荐答案
用英语:
如果DatabaseReference
指向users
节点,则使用getParent()
转到根节点,然后使用getChild(<UID here>)
获取对该节点的引用.
If your DatabaseReference
is pointing at the users
node, then use getParent()
to go to the root node, then use getChild(<UID here>)
to get a reference to that node.
Hindi Mein:
Hindi Mein:
琼脂aapke DatabaseReference
users
节点par ishaara kar raha hai,toh getParent ()
ka upayog karein,根节点tak jaane ke lie.菲尔getChild("UserInfo").getChild(<UID here>)
us node tak jaane ke lie.
agar aapke DatabaseReference
users
node par ishaara kar raha hai, toh getParent ()
ka upayog karein, root node tak jaane ke lie. Phir getChild("UserInfo").getChild(<UID here>)
us node tak jaane ke lie.
在代码中:
String uid = "CP9l8L1viLU77KrEOEDj2tNRCYq2"
DatabaseReference mRef = FirebaseDatabase.getInstance().getReference("users");
DatabaseReference refToYourUserid = mRef.getParent().getChild("UserInfo").getChild(uid);
这篇关于如何比较Firebase中的UID和另一个子键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!