Added support for $maxDistance (#179)

This commit is contained in:
Ross Lawley
2013-01-22 13:31:53 +00:00
parent 0b177ec4c1
commit 2c7b12c022
4 changed files with 17 additions and 1 deletions

View File

@@ -9,7 +9,8 @@ __all__ = ('query', 'update')
COMPARISON_OPERATORS = ('ne', 'gt', 'gte', 'lt', 'lte', 'in', 'nin', 'mod',
'all', 'size', 'exists', 'not')
GEO_OPERATORS = ('within_distance', 'within_spherical_distance',
'within_box', 'within_polygon', 'near', 'near_sphere')
'within_box', 'within_polygon', 'near', 'near_sphere',
'max_distance')
STRING_OPERATORS = ('contains', 'icontains', 'startswith',
'istartswith', 'endswith', 'iendswith',
'exact', 'iexact')
@@ -97,6 +98,8 @@ def query(_doc_cls=None, _field_operation=False, **query):
value = {'$nearSphere': value}
elif op == 'within_box':
value = {'$within': {'$box': value}}
elif op == "max_distance":
value = {'$maxDistance': value}
else:
raise NotImplementedError("Geo method '%s' has not "
"been implemented" % op)