I'm trying to figure out a way to geo query two collections:
Person {name, age, groupid}
Groups (id, name, geoLocation[x,y])
I need to find all near groups with persons with age > 18
Any idea how to do it without having to query the groups for each found person?
You have no joins in MongoDB so you need to find another way around this.
The next plausable method I would think of would be to store an array of age ranges with the group record:
{
_id: {},
name: {},
geoLocation: {},
age_groups: {
'gt18': 1
},
}
And then I would just query on that age_groups.gt18 field and pull out all records. This does mean, of course, you will require something to keep this field upto date. There are a couple of methods:
I would personally go for the event based pre-aggregated method of doing things