I'm trying to further reduce the number of results returned by GeoFire by a privacy value (i.e. if privacy == "public"
) I haven't found any good solutions about this and didn't see anything of this sort on GeoFire's Github page.
My current solution takes the GeoFire query and iterates through each checking for the value. I'm concerned this will be slow, and frankly doesn't feel right. Is there a more standard way I should be making this query?
circleQuery?.observe(.keyEntered, with: { (key: String!, location: CLLocation!) in
self.annotationLocationRef.child(key).observeSingleEvent(of: .value, with: { (locationSnapshot) in
if !locationSnapshot.exists() { return }
self.annotationRef.child(key).observeSingleEvent(of: .value, with: {(annotationSnapshot) in
if !annotationSnapshot.exists() { return }
let snapshotValue = annotationSnapshot.value as? NSDictionary
let privacy = snapshotValue!["privacy"] as? Double
if privacy == "public" {
// do stuff
}
})
}) { (error) in
print(error.localizedDescription)
}
})