nearestOffice()
Returns the nearest geographic Location, including only Office locations (no Remote locations), to a particular person, group, or address.
Syntax
nearestOffice(entity[, list])
Parameters
Parameter | Type | Description |
|---|---|---|
entity | The starting point to measure distance from | |
list | (Optional) A list of Groups to compare against. The one that is the nearest geographically, and is also an Office, will be returned. If this parameter is not provided, all Locations that are Offices will be compared. |
Return Type
Whichever entity provided in the list, or whichever Group Location is closest geographically, will be returned.
Examples
nearestOffice(person)
Returns the nearest Location, that is an office, to the person.
nearestLocation(person, db.group.find{type:location and name:atlanta,boston,orlando})
Returns which of the office locations matching "Atlanta", "Boston" or "Orlando" is closest to the current person.
