GeoNearOptions

public struct GeoNearOptions: ValueConvertible

Requires the resulting data to be near the provided point

Also allows further configuration of the query

Further information and details: https://docs.mongodb.com/manual/reference/command/geoNear/

  • The point which you’re looking near

    Declaration

    Swift

    public let near: Point
  • The output field that contains the calculated distance.

    Declaration

    Swift

    public let distanceField: String
  • If true, then MongoDB uses spherical geometry to calculate distances in meters if the specified (near) point is a GeoJSON point and in radians if the specified (near) point is a legacy coordinate pair.

    If false, then MongoDB uses 2d planar geometry to calculate distance between points.

    Declaration

    Swift

    public let spherical: Bool
  • Limits the returned results

    100 by default

    Declaration

    Swift

    public let limit: Int?
  • The minimum distance from the center point resulting Documents must be

    Declaration

    Swift

    public let minDistance: Double?
  • The maximum distance from the center point resulting Documents must be

    Declaration

    Swift

    public let maxDistance: Double?
  • Requires resulting documents to also match this query, besides the geolocation query

    Declaration

    Swift

    public let query: Query?
  • The factor to multiply all distances returned by the query. For example, use the distanceMultiplier to convert radians, as returned by a spherical query, to kilometers by multiplying by the radius of the Earth.

    Declaration

    Swift

    public let distanceMultiplier: Double?
  • Outputs each matching document once, even if multiple fields match the query

    Deprecated in 2.6

    Declaration

    Swift

    public let uniqueDocs: Bool?
  • This specifies the output field that identifies the location used to calculate the distance.

    Declaration

    Swift

    public let includeLocs: String?
  • Creates GeoNear options

    Declaration

    Swift

    public init(near: Point, spherical: Bool, distanceField: String, limit: Int? = nil, minDistance: Double? = nil, maxDistance: Double? = nil, query: Query? = nil, distanceMultiplier: Double? = nil, uniqueDocs: Bool? = nil, includeLocs: String? = nil)
  • Creates a Document for these options

    Declaration

    Swift

    public func makeDocument() -> Document
  • Makes this an embeddable primitive

    Declaration

    Swift

    public func makePrimitive() -> BSON.Primitive