Query.apex
Query.apex copied to clipboard
Support DISTANCE function
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_geolocate.htm
I haven't come up with a design yet.
Anyway, the feature is still available by manually feeding the whole DISTANCE expression to the first parameter of the methods addConditionXX or orderBy.
For example:
new Query('Account')
.addConditionGt('DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), \'mi\')', 10);
new Query('Account')
.orderBy('DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), \'mi\')', 'DESC');
It's just this way of coding does not fit the style of Query.apex.