Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GeoQuery

A GeoQuery refers to a Query which you can read or listen to. You can also construct refined GeoQuery objects by adding filters and ordering.

Hierarchy

Index

Constructors

constructor

  • Parameters

    • _query: Query | Query

      The Query instance.

    • Optional queryCriteria: QueryCriteria

      The query criteria of geo based queries, includes field such as center, radius, and limit.

    Returns GeoQuery

Properties

Private _center

_center: GeoPoint | GeoPoint

Private _isWeb

_isWeb: boolean

Private _limit

_limit: number

Private _query

_query: Query | Query

The Query instance.

Private _radius

_radius: number

Accessors

Private _queryCriteria

firestore

  • The Firestore for the Firestore database (useful for performing transactions, etc.).

    Returns GeoFirestore

onSnapshot

  • get onSnapshot(): function
  • Attaches a listener for GeoQuerySnapshot events.

    Returns function

    An unsubscribe function that can be called to cancel the snapshot listener.

      • (onNext: function, onError?: function): function
      • Parameters

        • onNext: function

          A callback to be called every time a new GeoQuerySnapshot is available.

        • Optional onError: function

          A callback to be called if the listen fails or is cancelled. Since multuple queries occur only the failed query will cease.

            • (error: Error): void
            • Parameters

              • error: Error

              Returns void

        Returns function

          • (): void
          • Returns void

Methods

Private _generateQuery

  • _generateQuery(): Query[]
  • Creates an array of Query objects that query the appropriate geohashes based on the radius and center GeoPoint of the query criteria.

    Returns Query[]

    Array of Queries to search against.

Private _queryToString

  • _queryToString(query: string[]): string
  • Encodes a query as a string for easier indexing and equality.

    Parameters

    • query: string[]

      The query to encode.

    Returns string

    The encoded query as string.

Private _stringToQuery

  • _stringToQuery(str: string): string[]
  • Decodes a query string to a query

    Parameters

    • str: string

      The encoded query.

    Returns string[]

    The decoded query as a [start, end] pair.

get

  • Executes the query and returns the results as a GeoQuerySnapshot.

    WEB CLIENT ONLY Note: By default, get() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. This behavior can be altered via the GetOptions parameter.

    Parameters

    • Default value options: GetOptions = { source: 'default' }

      An object to configure the get behavior.

    Returns Promise<GeoQuerySnapshot>

    A Promise that will be resolved with the results of the GeoQuery.

limit

  • Creates and returns a new GeoQuery that's additionally limited to only return up to the specified number of documents.

    This function returns a new (immutable) instance of the GeoQuery (rather than modify the existing instance) to impose the limit.

    Note: Limits on geoqueries are applied based on the distance from the center. Geoqueries require an aggregation of queries. When performing a geoquery the library applies the limit on the client. This may mean you are loading to the client more documents then you intended. Use with this performance limitation in mind.

    Parameters

    • limit: number

      The maximum number of items to return.

    Returns GeoQuery

    The created GeoQuery.

near

  • Creates and returns a new GeoQuery with the geoquery filter where get and onSnapshot will query around.

    This function returns a new (immutable) instance of the GeoQuery (rather than modify the existing instance) to impose the filter.

    Parameters

    Returns GeoQuery

    The created GeoQuery.

where

  • Creates and returns a new GeoQuery with the additional filter that documents must contain the specified field and that its value should satisfy the relation constraint provided.

    This function returns a new (immutable) instance of the GeoQuery (rather than modify the existing instance) to impose the filter.

    Parameters

    • fieldPath: string | FieldPath | FieldPath

      The path to compare

    • opStr: WhereFilterOp

      The operation string (e.g "<", "<=", "==", ">", ">=").

    • value: any

      The value for comparison

    Returns GeoQuery

    The created GeoQuery.

Generated using TypeDoc