I’d like to hear if anyone else has solved this problem. I have a possible solution. Do you think the additional complexity plus oplog is better than the poll/diff?
I could store zones for locations, and defined some granularity parameter: R = 1 mile, for example:
On inserting newDoc with location field, check if the location is within R of an existing zone.
If so, newDoc.zone = existingZone
Else, create a new zone with center newDoc.location, and set newDoc.zone = newZone.
In the publish function, the app will first static-query the zones around the user’s location, results in an array. Then use the result array to publish all docs within those zones. Use the added/changed/removed to compute the distance to the user on the fly in the publish function, since the user’s coords are an argument. The user can now sort by distance, from a live query which is oplog-enabled.
Is the additional complexity here (query to get zones, plus a zone collection) worth the oplog enabled? Another downside, perhaps the most obvious, is the discretization of the locational data, based on R. To be honest, this is not a problem in my app.