1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Support all GEORADIUS Commands (#2017)

* Support all GEORADIUS Commands

* move store bool to options

* simplify transformReply for store commands

* clean code

Co-authored-by: leibale <leibale1998@gmail.com>
This commit is contained in:
Avital Fine
2022-05-11 16:36:12 +03:00
committed by GitHub
parent 5c9f31f244
commit 06c1d2c243
23 changed files with 728 additions and 3 deletions

View File

@@ -32,6 +32,16 @@ import * as GEOADD from '../commands/GEOADD';
import * as GEODIST from '../commands/GEODIST'; import * as GEODIST from '../commands/GEODIST';
import * as GEOHASH from '../commands/GEOHASH'; import * as GEOHASH from '../commands/GEOHASH';
import * as GEOPOS from '../commands/GEOPOS'; import * as GEOPOS from '../commands/GEOPOS';
import * as GEORADIUS_RO_WITH from '../commands/GEORADIUS_RO_WITH';
import * as GEORADIUS_RO from '../commands/GEORADIUS_RO';
import * as GEORADIUS_WITH from '../commands/GEORADIUS_WITH';
import * as GEORADIUS from '../commands/GEORADIUS';
import * as GEORADIUSBYMEMBER_RO_WITH from '../commands/GEORADIUSBYMEMBER_RO_WITH';
import * as GEORADIUSBYMEMBER_RO from '../commands/GEORADIUSBYMEMBER_RO';
import * as GEORADIUSBYMEMBER_WITH from '../commands/GEORADIUSBYMEMBER_WITH';
import * as GEORADIUSBYMEMBER from '../commands/GEORADIUSBYMEMBER';
import * as GEORADIUSBYMEMBERSTORE from '../commands/GEORADIUSBYMEMBERSTORE';
import * as GEORADIUSSTORE from '../commands/GEORADIUSSTORE';
import * as GEOSEARCH_WITH from '../commands/GEOSEARCH_WITH'; import * as GEOSEARCH_WITH from '../commands/GEOSEARCH_WITH';
import * as GEOSEARCH from '../commands/GEOSEARCH'; import * as GEOSEARCH from '../commands/GEOSEARCH';
import * as GEOSEARCHSTORE from '../commands/GEOSEARCHSTORE'; import * as GEOSEARCHSTORE from '../commands/GEOSEARCHSTORE';
@@ -263,6 +273,26 @@ export default {
geoHash: GEOHASH, geoHash: GEOHASH,
GEOPOS, GEOPOS,
geoPos: GEOPOS, geoPos: GEOPOS,
GEORADIUS_RO_WITH,
geoRadiusRoWith: GEORADIUS_RO_WITH,
GEORADIUS_RO,
geoRadiusRo: GEORADIUS_RO,
GEORADIUS_WITH,
geoRadiusWith: GEORADIUS_WITH,
GEORADIUS,
geoRadius: GEORADIUS,
GEORADIUSBYMEMBER_RO_WITH,
geoRadiusByMemberRoWith: GEORADIUSBYMEMBER_RO_WITH,
GEORADIUSBYMEMBER_RO,
geoRadiusByMemberRo: GEORADIUSBYMEMBER_RO,
GEORADIUSBYMEMBER_WITH,
geoRadiusByMemberWith: GEORADIUSBYMEMBER_WITH,
GEORADIUSBYMEMBER,
geoRadiusByMember: GEORADIUSBYMEMBER,
GEORADIUSBYMEMBERSTORE,
geoRadiusByMemberStore: GEORADIUSBYMEMBERSTORE,
GEORADIUSSTORE,
geoRadiusStore: GEORADIUSSTORE,
GEOSEARCH_WITH, GEOSEARCH_WITH,
geoSearchWith: GEOSEARCH_WITH, geoSearchWith: GEOSEARCH_WITH,
GEOSEARCH, GEOSEARCH,

View File

@@ -0,0 +1,35 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GEORADIUS';
describe('GEORADIUS', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', {
longitude: 1,
latitude: 2
}, 3 , 'm'),
['GEORADIUS', 'key', '1', '2', '3', 'm']
);
});
testUtils.testWithClient('client.geoRadius', async client => {
assert.deepEqual(
await client.geoRadius('key', {
longitude: 1,
latitude: 2
}, 3 , 'm'),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.geoRadius', async cluster => {
assert.deepEqual(
await cluster.geoRadius('key', {
longitude: 1,
latitude: 2
}, 3 , 'm'),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -0,0 +1,25 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { GeoSearchOptions, GeoCoordinates, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
export const FIRST_KEY_INDEX = 1;
export const IS_READ_ONLY = true;
export function transformArguments(
key: RedisCommandArgument,
coordinates: GeoCoordinates,
radius: number,
unit: GeoUnits,
options?: GeoSearchOptions
): RedisCommandArguments {
return pushGeoRadiusArguments(
['GEORADIUS'],
key,
coordinates,
radius,
unit,
options
);
}
export declare function transformReply(): Array<RedisCommandArgument>;

View File

@@ -0,0 +1,26 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GEORADIUSBYMEMBER';
describe('GEORADIUSBYMEMBER', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 'member', 3 , 'm'),
['GEORADIUSBYMEMBER', 'key', 'member', '3', 'm']
);
});
testUtils.testWithClient('client.geoRadiusByMember', async client => {
assert.deepEqual(
await client.geoRadiusByMember('key', 'member', 3 , 'm'),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.geoRadiusByMember', async cluster => {
assert.deepEqual(
await cluster.geoRadiusByMember('key', 'member', 3 , 'm'),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -0,0 +1,25 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { GeoSearchOptions, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
export const FIRST_KEY_INDEX = 1;
export const IS_READ_ONLY = true;
export function transformArguments(
key: RedisCommandArgument,
member: string,
radius: number,
unit: GeoUnits,
options?: GeoSearchOptions
): RedisCommandArguments {
return pushGeoRadiusArguments(
['GEORADIUSBYMEMBER'],
key,
member,
radius,
unit,
options
);
}
export declare function transformReply(): Array<RedisCommandArgument>;

View File

@@ -0,0 +1,53 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './GEORADIUSBYMEMBERSTORE';
describe('GEORADIUSBYMEMBERSTORE', () => {
describe('transformArguments', () => {
it('STORE', () => {
assert.deepEqual(
transformArguments('key', 'member', 3 , 'm', 'dest', {
SORT: 'ASC',
COUNT: {
value: 1,
ANY: true
}
}),
['GEORADIUSBYMEMBER', 'key', 'member', '3', 'm', 'ASC', 'COUNT', '1', 'ANY', 'STORE', 'dest']
);
});
it('STOREDIST', () => {
assert.deepEqual(
transformArguments('key', 'member', 3 , 'm', 'dest', { STOREDIST: true }),
['GEORADIUSBYMEMBER', 'key', 'member', '3', 'm', 'STOREDIST', 'dest']
);
});
});
testUtils.testWithClient('client.geoRadiusByMemberStore', async client => {
await client.geoAdd('source', {
longitude: 1,
latitude: 1,
member: 'member'
});
assert.equal(
await client.geoRadiusByMemberStore('source', 'member', 3 , 'm', 'dest'),
1
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.geoRadiusByMemberStore', async cluster => {
await cluster.geoAdd('{tag}source', {
longitude: 1,
latitude: 1,
member: 'member'
});
assert.equal(
await cluster.geoRadiusByMemberStore('{tag}source', 'member', 3 , 'm','{tag}destination'),
1
);
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -0,0 +1,25 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { GeoUnits, GeoRadiusStoreOptions, pushGeoRadiusStoreArguments } from './generic-transformers';
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUSBYMEMBER';
export function transformArguments(
key: RedisCommandArgument,
member: string,
radius: number,
unit: GeoUnits,
destination: RedisCommandArgument,
options?: GeoRadiusStoreOptions,
): RedisCommandArguments {
return pushGeoRadiusStoreArguments(
['GEORADIUSBYMEMBER'],
key,
member,
radius,
unit,
destination,
options
);
}
export declare function transformReply(): number

View File

@@ -0,0 +1,26 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GEORADIUSBYMEMBER_RO';
describe('GEORADIUSBYMEMBER_RO', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 'member', 3 , 'm'),
['GEORADIUSBYMEMBER_RO', 'key', 'member', '3', 'm']
);
});
testUtils.testWithClient('client.geoRadiusByMemberRo', async client => {
assert.deepEqual(
await client.geoRadiusByMemberRo('key', 'member', 3 , 'm'),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.geoRadiusByMemberRo', async cluster => {
assert.deepEqual(
await cluster.geoRadiusByMemberRo('key', 'member', 3 , 'm'),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -0,0 +1,25 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { GeoSearchOptions, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
export const FIRST_KEY_INDEX = 1;
export const IS_READ_ONLY = true;
export function transformArguments(
key: RedisCommandArgument,
member: string,
radius: number,
unit: GeoUnits,
options?: GeoSearchOptions
): RedisCommandArguments {
return pushGeoRadiusArguments(
['GEORADIUSBYMEMBER_RO'],
key,
member,
radius,
unit,
options
);
}
export declare function transformReply(): Array<RedisCommandArgument>;

View File

@@ -0,0 +1,31 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { RedisCommandArguments } from '.';
import { GeoReplyWith } from './generic-transformers';
import { transformArguments } from './GEORADIUSBYMEMBER_RO_WITH';
describe('GEORADIUSBYMEMBER_RO WITH', () => {
it('transformArguments', () => {
const expectedReply: RedisCommandArguments = ['GEORADIUSBYMEMBER_RO', 'key', 'member', '3', 'm', 'WITHDIST'];
expectedReply.preserve = ['WITHDIST'];
assert.deepEqual(
transformArguments('key', 'member', 3 , 'm', [GeoReplyWith.DISTANCE]),
expectedReply
);
});
testUtils.testWithClient('client.geoRadiusByMemberRoWith', async client => {
assert.deepEqual(
await client.geoRadiusByMemberRoWith('key', 'member', 3 , 'm', [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.geoRadiusByMemberRoWith', async cluster => {
assert.deepEqual(
await cluster.geoRadiusByMemberRoWith('key', 'member', 3 , 'm', [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -0,0 +1,30 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { GeoReplyWith, GeoSearchOptions, GeoUnits } from './generic-transformers';
import { transformArguments as geoRadiusTransformArguments } from './GEORADIUSBYMEMBER_RO';
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUSBYMEMBER_RO';
export function transformArguments(
key: RedisCommandArgument,
member: string,
radius: number,
unit: GeoUnits,
replyWith: Array<GeoReplyWith>,
options?: GeoSearchOptions
): RedisCommandArguments {
const args: RedisCommandArguments = geoRadiusTransformArguments(
key,
member,
radius,
unit,
options
);
args.push(...replyWith);
args.preserve = replyWith;
return args;
}
export { transformGeoMembersWithReply as transformReply } from './generic-transformers';

View File

@@ -0,0 +1,31 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { RedisCommandArguments } from '.';
import { GeoReplyWith } from './generic-transformers';
import { transformArguments } from './GEORADIUSBYMEMBER_WITH';
describe('GEORADIUSBYMEMBER WITH', () => {
it('transformArguments', () => {
const expectedReply: RedisCommandArguments = ['GEORADIUSBYMEMBER', 'key', 'member', '3', 'm', 'WITHDIST'];
expectedReply.preserve = ['WITHDIST'];
assert.deepEqual(
transformArguments('key', 'member', 3 , 'm', [GeoReplyWith.DISTANCE]),
expectedReply
);
});
testUtils.testWithClient('client.geoRadiusByMemberWith', async client => {
assert.deepEqual(
await client.geoRadiusByMemberWith('key', 'member', 3 , 'm', [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.geoRadiusByMemberWith', async cluster => {
assert.deepEqual(
await cluster.geoRadiusByMemberWith('key', 'member', 3 , 'm', [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -0,0 +1,30 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { GeoReplyWith, GeoSearchOptions, GeoUnits } from './generic-transformers';
import { transformArguments as transformGeoRadiusArguments } from './GEORADIUSBYMEMBER';
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUSBYMEMBER';
export function transformArguments(
key: RedisCommandArgument,
member: string,
radius: number,
unit: GeoUnits,
replyWith: Array<GeoReplyWith>,
options?: GeoSearchOptions
): RedisCommandArguments {
const args: RedisCommandArguments = transformGeoRadiusArguments(
key,
member,
radius,
unit,
options
);
args.push(...replyWith);
args.preserve = replyWith;
return args;
}
export { transformGeoMembersWithReply as transformReply } from './generic-transformers';

View File

@@ -0,0 +1,53 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './GEORADIUSSTORE';
describe('GEORADIUSSTORE', () => {
describe('transformArguments', () => {
it('STORE', () => {
assert.deepEqual(
transformArguments('key', {longitude: 1, latitude: 2}, 3 , 'm', 'dest', {
SORT: 'ASC',
COUNT: {
value: 1,
ANY: true
}
}),
['GEORADIUS', 'key', '1', '2', '3', 'm', 'ASC', 'COUNT', '1', 'ANY', 'STORE', 'dest']
);
});
it('STOREDIST', () => {
assert.deepEqual(
transformArguments('key', {longitude: 1, latitude: 2}, 3 , 'm', 'dest', { STOREDIST: true }),
['GEORADIUS', 'key', '1', '2', '3', 'm', 'STOREDIST', 'dest']
);
});
});
testUtils.testWithClient('client.geoRadiusStore', async client => {
await client.geoAdd('source', {
longitude: 1,
latitude: 1,
member: 'member'
});
assert.equal(
await client.geoRadiusStore('source', {longitude: 1, latitude: 1}, 3 , 'm', 'dest'),
1
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.geoRadiusStore', async cluster => {
await cluster.geoAdd('{tag}source', {
longitude: 1,
latitude: 1,
member: 'member'
});
assert.equal(
await cluster.geoRadiusStore('{tag}source', {longitude: 1, latitude: 1}, 3 , 'm', '{tag}destination'),
1
);
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -0,0 +1,25 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { GeoCoordinates, GeoUnits, GeoRadiusStoreOptions, pushGeoRadiusStoreArguments } from './generic-transformers';
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUS';
export function transformArguments(
key: RedisCommandArgument,
coordinates: GeoCoordinates,
radius: number,
unit: GeoUnits,
destination: RedisCommandArgument,
options?: GeoRadiusStoreOptions,
): RedisCommandArguments {
return pushGeoRadiusStoreArguments(
['GEORADIUS'],
key,
coordinates,
radius,
unit,
destination,
options
);
}
export declare function transformReply(): number;

View File

@@ -0,0 +1,35 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GEORADIUS_RO';
describe('GEORADIUS_RO', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', {
longitude: 1,
latitude: 2
}, 3 , 'm'),
['GEORADIUS_RO', 'key', '1', '2', '3', 'm']
);
});
testUtils.testWithClient('client.geoRadiusRo', async client => {
assert.deepEqual(
await client.geoRadiusRo('key', {
longitude: 1,
latitude: 2
}, 3 , 'm'),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.geoRadiusRo', async cluster => {
assert.deepEqual(
await cluster.geoRadiusRo('key', {
longitude: 1,
latitude: 2
}, 3 , 'm'),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -0,0 +1,25 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { GeoSearchOptions, GeoCoordinates, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
export const FIRST_KEY_INDEX = 1;
export const IS_READ_ONLY = true;
export function transformArguments(
key: RedisCommandArgument,
coordinates: GeoCoordinates,
radius: number,
unit: GeoUnits,
options?: GeoSearchOptions
): RedisCommandArguments {
return pushGeoRadiusArguments(
['GEORADIUS_RO'],
key,
coordinates,
radius,
unit,
options
);
}
export declare function transformReply(): Array<RedisCommandArgument>;

View File

@@ -0,0 +1,40 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { RedisCommandArguments } from '.';
import { GeoReplyWith } from './generic-transformers';
import { transformArguments } from './GEORADIUS_RO_WITH';
describe('GEORADIUS_RO WITH', () => {
it('transformArguments', () => {
const expectedReply: RedisCommandArguments = ['GEORADIUS_RO', 'key', '1', '2', '3', 'm', 'WITHDIST'];
expectedReply.preserve = ['WITHDIST'];
assert.deepEqual(
transformArguments('key', {
longitude: 1,
latitude: 2
}, 3 , 'm', [GeoReplyWith.DISTANCE]),
expectedReply
);
});
testUtils.testWithClient('client.geoRadiusRoWith', async client => {
assert.deepEqual(
await client.geoRadiusRoWith('key', {
longitude: 1,
latitude: 2
}, 3 , 'm', [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.geoRadiusReadOnlyWith', async cluster => {
assert.deepEqual(
await cluster.geoRadiusRoWith('key', {
longitude: 1,
latitude: 2
}, 3 , 'm', [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -0,0 +1,30 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { GeoReplyWith, GeoSearchOptions, GeoCoordinates, GeoUnits } from './generic-transformers';
import { transformArguments as transformGeoRadiusRoArguments } from './GEORADIUS_RO';
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUS_RO';
export function transformArguments(
key: RedisCommandArgument,
coordinates: GeoCoordinates,
radius: number,
unit: GeoUnits,
replyWith: Array<GeoReplyWith>,
options?: GeoSearchOptions
): RedisCommandArguments {
const args: RedisCommandArguments = transformGeoRadiusRoArguments(
key,
coordinates,
radius,
unit,
options
);
args.push(...replyWith);
args.preserve = replyWith;
return args;
}
export { transformGeoMembersWithReply as transformReply } from './generic-transformers';

View File

@@ -0,0 +1,40 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { RedisCommandArguments } from '.';
import { GeoReplyWith } from './generic-transformers';
import { transformArguments } from './GEORADIUS_WITH';
describe('GEORADIUS WITH', () => {
it('transformArguments', () => {
const expectedReply: RedisCommandArguments = ['GEORADIUS', 'key', '1', '2', '3', 'm', 'WITHDIST'];
expectedReply.preserve = ['WITHDIST'];
assert.deepEqual(
transformArguments('key', {
longitude: 1,
latitude: 2
}, 3 , 'm', [GeoReplyWith.DISTANCE]),
expectedReply
);
});
testUtils.testWithClient('client.geoRadiusWith', async client => {
assert.deepEqual(
await client.geoRadiusWith('key', {
longitude: 1,
latitude: 2
}, 3 , 'm', [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.geoRadiusWith', async cluster => {
assert.deepEqual(
await cluster.geoRadiusWith('key', {
longitude: 1,
latitude: 2
}, 3 , 'm', [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -0,0 +1,30 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { GeoReplyWith, GeoSearchOptions, GeoCoordinates, GeoUnits } from './generic-transformers';
import { transformArguments as transformGeoRadiusArguments } from './GEORADIUS';
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUS';
export function transformArguments(
key: RedisCommandArgument,
coordinates: GeoCoordinates,
radius: number,
unit: GeoUnits,
replyWith: Array<GeoReplyWith>,
options?: GeoSearchOptions
): RedisCommandArguments {
const args: RedisCommandArguments = transformGeoRadiusArguments(
key,
coordinates,
radius,
unit,
options
);
args.push(...replyWith);
args.preserve = replyWith;
return args;
}
export { transformGeoMembersWithReply as transformReply } from './generic-transformers';

View File

@@ -1,9 +1,7 @@
import { RedisCommandArgument, RedisCommandArguments } from '.'; import { RedisCommandArgument, RedisCommandArguments } from '.';
import { GeoSearchFrom, GeoSearchBy, GeoSearchOptions, pushGeoSearchArguments } from './generic-transformers'; import { GeoSearchFrom, GeoSearchBy, GeoSearchOptions, pushGeoSearchArguments } from './generic-transformers';
export const FIRST_KEY_INDEX = 1; export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEOSEARCH';
export const IS_READ_ONLY = true;
interface GeoSearchStoreOptions extends GeoSearchOptions { interface GeoSearchStoreOptions extends GeoSearchOptions {
STOREDIST?: true; STOREDIST?: true;

View File

@@ -286,6 +286,63 @@ export function pushGeoSearchArguments(
return args; return args;
} }
export function pushGeoRadiusArguments(
args: RedisCommandArguments,
key: RedisCommandArgument,
from: GeoSearchFrom,
radius: number,
unit: GeoUnits,
options?: GeoSearchOptions
): RedisCommandArguments {
args.push(key);
if (typeof from === 'string') {
args.push(from);
} else {
args.push(
from.longitude.toString(),
from.latitude.toString()
);
}
args.push(
radius.toString(),
unit
);
if (options?.SORT) {
args.push(options.SORT);
}
pushGeoCountArgument(args, options?.COUNT);
return args;
}
export interface GeoRadiusStoreOptions extends GeoSearchOptions {
STOREDIST?: boolean;
}
export function pushGeoRadiusStoreArguments(
args: RedisCommandArguments,
key: RedisCommandArgument,
from: GeoSearchFrom,
radius: number,
unit: GeoUnits,
destination: RedisCommandArgument,
options?: GeoRadiusStoreOptions
): RedisCommandArguments {
pushGeoRadiusArguments(args, key, from, radius, unit, options);
if (options?.STOREDIST) {
args.push('STOREDIST', destination);
} else {
args.push('STORE', destination);
}
return args;
}
export enum GeoReplyWith { export enum GeoReplyWith {
DISTANCE = 'WITHDIST', DISTANCE = 'WITHDIST',
HASH = 'WITHHASH', HASH = 'WITHHASH',