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.
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
When querying with
near()
using the the EXACT coordinates a document has, that returned doc is missing thedistance
property, whiledoc.distance
should be0
. This is causing issues for me when sorting based on distance. Right now I resolve it by defaulting the distance to 0:Relevant Code
Will be able to create a Stackblitz later if necessary.