You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-22 05:32:45 +03:00
implement some GEO commands, improve scan generic transformer, expose RPUSHX
This commit is contained in:
40
lib/commands/GEOSEARCHSTORE.ts
Normal file
40
lib/commands/GEOSEARCHSTORE.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { GeoSearchFrom, GeoSearchBy, GeoSearchOptions, pushGeoSearchArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
interface GeoSearchStoreOptions extends GeoSearchOptions {
|
||||
STOREDIST?: true;
|
||||
}
|
||||
|
||||
export function transformArguments(
|
||||
destination: string,
|
||||
source: string,
|
||||
from: GeoSearchFrom,
|
||||
by: GeoSearchBy,
|
||||
options?: GeoSearchStoreOptions
|
||||
): Array<string> {
|
||||
const args = pushGeoSearchArguments(
|
||||
['GEOSEARCHSTORE', destination],
|
||||
source,
|
||||
from,
|
||||
by,
|
||||
options
|
||||
);
|
||||
|
||||
if (options?.STOREDIST) {
|
||||
args.push('STOREDIST');
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
// in versions 6.2.0-6.2.4 Redis will return an empty array when `src` is empty
|
||||
// TODO: issue/PR
|
||||
export function transformReply(reply: number | []): number {
|
||||
if (typeof reply === 'number') return reply;
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user