Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 有没有办法在redis Service上的GEOADD方法中添加Date属性_Node.js_Redis_Node Redis - Fatal编程技术网

Node.js 有没有办法在redis Service上的GEOADD方法中添加Date属性

Node.js 有没有办法在redis Service上的GEOADD方法中添加Date属性,node.js,redis,node-redis,Node.js,Redis,Node Redis,需要以下geoadd代码的帮助吗 _ client.geoadd('drivers_locations', coordinates[0], coordinates[1], driverID ,new Date().toString()); 否,没有可用于的时间维度 根据您正在做的事情,您可以通过将时间按不同的键来模拟它,如 const key = `drivers_locations_${Math.floor(+new Date() / 1000 / 60)`; client.geoadd(k

需要以下geoadd代码的帮助吗

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

否,没有可用于的时间维度

根据您正在做的事情,您可以通过将时间按不同的键来模拟它,如

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

但是查询变得更加复杂。

虽然
GEOADD
不支持此功能,但您可以将日期属性存储在另一个键中,例如:

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

在redis中是否有其他方法可用于根据键添加/更新和获取日期属性?这取决于你最终想要实现什么。