When querying `near`: `distance` prop is missing when distance is 0
mthomas-io opened this issue · comments
[REQUIRED] Describe your environment
- firebase-admin@8.13.0
- GeoFirestore version: 4.4.1
[REQUIRED] Describe the problem
When querying with near()
using the the EXACT coordinates a document has, that returned doc is missing the distance
property, while doc.distance
should be 0
. This is causing issues for me when sorting based on distance. Right now I resolve it by defaulting the distance to 0:
// When geocollection is queried with EXACT coordinates of a doc, that doc
// won't have a `distance` prop. Therefore we default the distance to 0.
result = result.sort((docA, docB) => (docA.distance || 0) - (docB.distance || 0));
Relevant Code
Will be able to create a Stackblitz later if necessary.
Sorry for the delay in responding, but are you including a radius in your query?
Separately here's a stackblitz showing that the distance is in the object (check the console in the preview).