Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GeoCollectionReference

A GeoCollectionReference object can be used for adding documents, getting document references, and querying for documents (using the methods inherited from GeoQuery).

Hierarchy

Index

Constructors

Accessors

  • Returns the center and radius of geo based queries as a QueryCriteria object.

    Returns QueryCriteria

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

    Returns GeoFirestore

  • get id(): string
  • get onSnapshot(): (onNext: (snapshot: GeoQuerySnapshot) => void, onError?: (error: Error) => void) => () => void
  • Attaches a listener for GeoQuerySnapshot events.

    Returns (onNext: (snapshot: GeoQuerySnapshot) => void, onError?: (error: Error) => void) => () => void

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

      • (onNext: (snapshot: GeoQuerySnapshot) => void, onError?: (error: Error) => void): () => void
      • Attaches a listener for GeoQuerySnapshot events.

        Parameters

        • onNext: (snapshot: GeoQuerySnapshot) => void

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

            • (snapshot: GeoQuerySnapshot): void
            • Parameters

              • snapshot: GeoQuerySnapshot

              Returns void

        • Optional onError: (error: Error) => void

          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 () => void

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

          • (): void
          • Returns void

  • get path(): string

Methods

  • Add a new document to this collection with the specified data, assigning it a document ID automatically.

    Parameters

    • documentData: DocumentData

      An Object containing the data for the new document.

    • customKey: string = ...

      The key of the document to use as the location. Otherwise we default to coordinates.

    Returns Promise<GeoDocumentReference>

    A Promise resolved with a GeoDocumentReference pointing to the newly created document after it has been written to the backend.

  • Get a GeoDocumentReference for the document within the collection at the specified path. If no path is specified, an automatically-generated unique ID will be used for the returned GeoDocumentReference.

    Parameters

    • Optional documentPath: string

      A slash-separated path to a document.

    Returns GeoDocumentReference

    The GeoDocumentReference instance.

  • get(options?: GetOptions): Promise<GeoQuerySnapshot>
  • 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

    • options: GetOptions = ...

      An object to configure the get behavior.

    Returns Promise<GeoQuerySnapshot>

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

  • 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.

  • 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.

  • 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