'How to retrieve coordinates with redis on NodeJS
I make a real time location server with nodejs and redis. I would like to retrieve longitude and lattitude with the geoSearch command.
const drivers = await server.redis.geoSearch('drivers', {latitude, longitude}, {radius: 5, unit: 'km'})
With these parameters I can only the members of key drivers.
Solution 1:[1]
There's a nice pretty way to do that with Node Redis that doesn't work right now. I'm submitting a PR to get it fixed right after this message. It looks like this:
const drivers = await redis.geoSearchWith(
'drivers',
{ latitude, longitude },
{ radius: 5, unit: 'km' },
[GeoReplyWith.COORDINATES])
The problem is that Node Redis doesn't expose the GeoReplyWith type. This is easily remedied by just passing in a string:
const drivers = await server.redis.geoSearchWith(
'drivers',
{ latitude, longitude },
{ radius: 50, unit: 'km' },
['COORDINATES'])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Guy Royse |
