JuFa512
JuFa512

Reputation: 159

Firebase look in child(uid) for child(currentUid) swift

I want to look into a child to look for another child. I want to find my current Uid in someone elses uid. How do I do that?

guard let currentUid = Auth.auth.currentUser?.uid else { return }
guard let (this is missing) = ... else { return } 

Database.database().reference().child("users-following").child(" ... ").child(currentUid)

The "this is missing" and child("...") indicate, where I am not getting anywhere. Can someone help me? I want to look in this child("…") to check and see if my currentUid is in that list.

______ UPDATE _______

"user-followers : {
  "YsBqvPlRGMfx..." : {
    "iFjaXB7lI..." : 1 
  }
},

iFjaXB... is the user, that deletes the account. All his data is being deleted as it's supposed to. But the id stays within the YsBq child in the "user-followers". So, I want to delete the child "iFjaXB" in the child of "YsBq". How do I do this?

Upvotes: 2

Views: 121

Answers (1)

JuFa512
JuFa512

Reputation: 159

I got things going. This is how:

Database.database().reference().child("here you put the one, that stores your currentUid".child(currentUid).observe(.childAdded) { (snapshot) in
let key = snapshot.key

Database.database().reference().child("user-followers).child(key).child(currentUid).removeValue()

Upvotes: 1

Related Questions