Huzefa Khan
Huzefa Khan

Reputation: 157

Is there any way to add Date attribute in GEOADD method on redis serve

Need Help in Following geoadd code

_ client.geoadd('drivers_locations', coordinates[0], coordinates[1], driverID ,new Date().toString());

Upvotes: 1

Views: 296

Answers (2)

Itamar Haber
Itamar Haber

Reputation: 49962

While GEOADD doesn't support this, you can store the date property in another key, e.g. something like this:

client.geoadd('drivers_locations', coordinates[0], coordinates[1], driverID);
client.hset('driver:' + id, 'date', ,ew Date().toString());

Upvotes: 0

AKX
AKX

Reputation: 169051

No, there is no time dimension available for GEOADD.

Depending on what you're doing, you might be able to emulate this by bucketing time into various keys, like

const key = `drivers_locations_${Math.floor(+new Date() / 1000 / 60)`;
client.geoadd(key, lon, lat, driverID);

but then querying becomes more complicated.

Upvotes: 1

Related Questions