I have the following structure in my firebase database.
"friendRequest" : {
"uid" : {
"-KUT7mxTW7WGLkgrZVM4" : {
"fromUid" : "uid"
}
}
}
In my iOS app, a user can make a friend request, similar in principle to adding friends on Facebook.
I need to access the fromUid property but I don't know the parent key above it which is generated by childByAutoId() (the third line - "-KUT7mxTW7WGLkgrZVM4").
How can I access the fromUid
key to get its value?
I think you're looking for something like:
ref.child("friendRequest")
.child(FIRAuth.auth()?.currentUser.uid)
.queryOrdered(byChild: "fromId")
.queryEqual(toValue: "theUidThatYou'reLookingFor")
.observeSingleEvent(of: .childAdded, with: { (snapshot) in
print("\(snapshot.key)")
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.