Reputation: 247
I am using firebase as backend and I want all user id with status false.
What I am trying in my code:-
ref.child("users").child((Auth.auth().currentUser?.uid)!).child("status").queryOrdered(byChild: "status").queryEqual(toValue : "false").observe(.value) { (snapshot: DataSnapshot) in
if let snapshot = snapshot.children.allObjects as? [DataSnapshot] {
print("SNAPSHOT: \(snapshot)")
for snap in snapshot {
if let postDict = snap.value as? Dictionary<String, AnyObject> {
let key = snap.key
print(key)
print(postDict)
}
}
}
}
Upvotes: 0
Views: 1669
Reputation: 401
Find sample code below. Just verify syntax once.
ref.child("users").observe(DataEventType.value, with: { (snapshot) in
if let snapshot = snapshot.children.allObjects as? [DataSnapshot] {
print("SNAPSHOT: \(snapshot)")
for snap in snapshot {
if let userDict = snap.value as? Dictionary<String, AnyObject> {
if userDict["Status"] as? Bool == false {
let key = snap.key
print(key)
//Add this key to userID array
}
}
}
}
}
Upvotes: 1