Class: Parse::Constraint::GeoIntersectsGeometryQueryConstraint

Inherits:
Constraint
  • Object
show all
Defined in:
lib/parse/query/constraints.rb

Overview

MongoDB-direct $geoIntersects with a full $geometry operand — NOT a Parse Server REST operator. Returns documents whose stored geometry intersects the supplied GeoJSON shape. Works against any 2dsphere-indexed column, including the :object columns where GeoJSON::LineString / GeoJSON::MultiPolygon geometries live.

Because Parse Server's REST find layer cannot express this operator, any query using :field.geo_intersects auto-routes through the mongo-direct path (see Query#requires_mongo_direct?). The routing gate requires use_master_key: true on the query AND a configured MongoDB client — per-row ACL/CLP enforcement and beforeFind/afterFind cloud triggers do not run on the mongo-direct path. Use this constraint only when those concerns are acceptable for the call site.

route = Parse::GeoJSON::LineString.new [[-122.4, 37.7], [-122.39, 37.78]] Region.query(:area.geo_intersects => route, :use_master_key => true).results

Version:

  • 4.4.0

Instance Method Summary collapse

Instance Method Details

#buildHash

Returns the compiled constraint, carrying the __mongo_direct_only routing marker so the query layer can auto-route to Query#results_direct.

Returns:

  • (Hash)

    the compiled constraint, carrying the __mongo_direct_only routing marker so the query layer can auto-route to Query#results_direct.



2036
2037
2038
2039
2040
2041
2042
2043
2044
# File 'lib/parse/query/constraints.rb', line 2036

def build
  geometry = coerce_to_geojson(formatted_value)
  {
    @operation.operand => {
      :$geoIntersects => { :$geometry => geometry },
    },
    "__mongo_direct_only" => true,
  }
end

#geo_intersectsGeoIntersectsGeometryQueryConstraint

A registered method on a symbol to create the constraint. Maps to MongoDB's $geoIntersects with the $geometry operand. Direct-only.

Examples:

q.where :area.geo_intersects => parse_geojson_geometry

Returns:



2030
# File 'lib/parse/query/constraints.rb', line 2030

constraint_keyword :$geoIntersects