Skip to content

generateGeoQueryDocumentSnapshotI() returns ...Data instead of ...Snapshot #6

@spoxies

Description

@spoxies

Currently the method generateGeoQueryDocumentSnapshot() returns a QueryDocumentSnapshot.
This only exposes a few methods or properties compared to a Firebase QueryDocumentSnapshot.

This means that what one can expect from either a generic Query or a GeoQuery is very different,
making passing results to generic functions a bit non unified (talking about geofirestore-js here).

With version v2.2.3 of geofirestore-js I had patched (but not PR'ed) theQueryDocumentSnapshot.
So it would expose QueryDocumentSnapshot methods, making it a drop-in replacement/addition.

As a sketch/conversation starter I did the same thing for the 5.0.0 version of geofirestore-core
This means that the implementing geofirestore-js would start to return the missing methods.

Now I say as a sketch, because I struggle with TypeScipt ( hence :any ),
and there are probably some semantics or reasons to take into account.

The commit does a few things.

Types

  • It renames the type GeoFirestoreTypes.QueryDocumentSnapshot to GeoFirestoreTypes.QueryDocumentSnapshotData, as the type was more ...Data than ...Snapshot
    • for the method decodeGeoQueryDocumentSnapshotData(), type QueryDocumentSnapshotData is still semantically valid and used
  • The previous, type GeoFirestoreTypes.QueryDocumentSnapshot is updated to extend the Firebase.QueryDocumentSnapshot type, (exposing all methods) and adding distance : number

Methods

  • generateGeoQueryDocumentSnapshot() now returns the original snapshot methods, and properties, but overwriting data() with decoded.data() and adding {distance : decoded.distance}

I wonder if this would be a good addition or if there are reasons why (not) to return the original snapshots.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions