[ad_1]
I’ve created a file and members can be part of utilizing becoming a member of code, I’ve to verify if that joinning code exists in database then add that member below that file the place becoming a member of code exists and particulars are in param parameter.
Means add a brand new baby in that file id named member with subchild param
I’ve hooked up the code under, please let me know the place is the issue.
I’ve additionally hooked up firebase database screenshots for each earlier than and after iteration.
static func joinCommettie(params: dictionaryParameter, _ committeeID: Int, completion: @escaping(_ standing:Bool, _ message: String)-> Void) {
ref = Database.database().reference(withPath: International.shared.COMMITTEES)
ref.queryOrdered(byChild: "joinningCode").queryEqual(toValue: committeeID).observeSingleEvent(of: .worth) { (snap) in
print(snap)
if snap.exists() {
print("-------Commettie Knowledge exists--------")
if let dict = snap.worth as? [String: Any] {
if let id = dict["id"] as? String {
ref.baby(id).baby("members").childByAutoId().setValue(params) {
(error:Error?, ref:DatabaseReference) in
if let error = error {
print("Knowledge couldn't be saved: (error).")
completion(false,error.localizedDescription)
} else {
print("Knowledge saved efficiently!")
completion(true,"Committee joined.")
}
}
}
}
} else {
completion(false,"No such committee exists.")
}
}
}
[ad_2]


