If you have a firebase snapshot that you are filtering for the current user, how do you do that for all users in the database?
Path: (people.child(uid).child(peopleWhoLike2)
It works for the current user, but I want it for all users. Probably something like for peopleArray in snapshot.children.allObjects as! [DataSnapshot] { needs to be used. Below is code for current
let thisUserRef1 = Database.database().reference().child("people").child(uid)
let myPeopleRef1 = thisUserRef1.child("peopleWhoLike2")
myPeopleRef1.observeSingleEvent(of:DataEventType.value, with: { snapshot in
print("klk")
let peopleArray = snapshot.children.allObjects as! [DataSnapshot]
let filteredResults = peopleArray.filter { person in
let personUid = person.value as! Int
let coordSnap12 = personUid
print("kjk", coordSnap12 )
let date = Date(timeIntervalSince1970: TimeInterval(coordSnap12)/1000.0)
//let secondsInDay = 86400
return Calendar.current.isDateInToday(date)
}
print(filteredResults, "ppp")
let countb = filteredResults.compactMap({$0}).count
print(countb, "ccc")
JSON DB Structure
"people" : {
"1ZWT7FAE2qThNQfBj7tbMO7BnMo1" : {
"Coordinates" : {
"latitude" : 50.054738,
"longitude" : 8.226809826085624
"peopleWhoLike2" : {
"1vLVFwrXrHUoakmDrnQKwbv08Yj1" : 1581548952597,
"F9NX0UCG4fVHCKFk2VZ1NZKsLro2" : 1586210112155,
"IrrBgFY9C1ekMmHUkQRzc5LhbDu1" : 1581547417432,