1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

Merge branch 'master' of github.com:redis/node-redis into v5

This commit is contained in:
Leibale
2023-06-19 18:11:46 -04:00
31 changed files with 620 additions and 49 deletions

View File

@@ -454,6 +454,13 @@ describe('AGGREGATE', () => {
['FT.AGGREGATE', 'index', '*', 'DIALECT', '1']
);
});
it('with TIMEOUT', () => {
assert.deepEqual(
transformArguments('index', '*', { TIMEOUT: 10 }),
['FT.AGGREGATE', 'index', '*', 'TIMEOUT', '10']
);
});
});
testUtils.testWithClient('client.ft.aggregate', async client => {

View File

@@ -124,6 +124,7 @@ export interface AggregateOptions {
STEPS?: Array<GroupByStep | SortStep | ApplyStep | LimitStep | FilterStep>;
PARAMS?: Params;
DIALECT?: number;
TIMEOUT?: number;
}
export const FIRST_KEY_INDEX = 1;
@@ -213,6 +214,10 @@ export function pushAggregatehOptions(
args.push('DIALECT', options.DIALECT.toString());
}
if (options?.TIMEOUT !== undefined) {
args.push('TIMEOUT', options.TIMEOUT.toString());
}
return args;
}

View File

@@ -4,15 +4,24 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CURSOR_READ';
describe('CURSOR READ', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('index', 0),
['FT.CURSOR', 'READ', 'index', '0']
);
describe('transformArguments', () => {
it('without options', () => {
assert.deepEqual(
transformArguments('index', 0),
['FT.CURSOR', 'READ', 'index', '0']
);
});
it('with COUNT', () => {
assert.deepEqual(
transformArguments('index', 0, { COUNT: 1 }),
['FT.CURSOR', 'READ', 'index', '0', 'COUNT', '1']
);
});
});
testUtils.testWithClient('client.ft.cursorRead', async client => {
const [ ,, { cursor } ] = await Promise.all([
const [, , { cursor }] = await Promise.all([
client.ft.create('idx', {
field: {
type: SchemaFieldTypes.TEXT

View File

@@ -4,16 +4,27 @@ export const FIRST_KEY_INDEX = 1;
export const IS_READ_ONLY = true;
interface CursorReadOptions {
COUNT?: number;
}
export function transformArguments(
index: RedisCommandArgument,
cursor: number
cursor: number,
options?: CursorReadOptions
): RedisCommandArguments {
return [
const args = [
'FT.CURSOR',
'READ',
index,
cursor.toString()
];
if (options?.COUNT) {
args.push('COUNT', options.COUNT.toString());
}
return args;
}
export { transformReply } from './AGGREGATE_WITHCURSOR';

View File

@@ -233,6 +233,15 @@ describe('SEARCH', () => {
['FT.SEARCH', 'index', 'query', 'DIALECT', '1']
);
});
it('with TIMEOUT', () => {
assert.deepEqual(
transformArguments('index', 'query', {
TIMEOUT: 5
}),
['FT.SEARCH', 'index', 'query', 'TIMEOUT', '5']
);
});
});
describe('client.ft.search', () => {

View File

@@ -55,6 +55,7 @@ export interface SearchOptions {
};
PARAMS?: Params;
DIALECT?: number;
TIMEOUT?: number;
}
export function transformArguments(

View File

@@ -510,6 +510,10 @@ export function pushSearchOptions(
args.preserve = true;
}
if (options?.TIMEOUT !== undefined) {
args.push('TIMEOUT', options.TIMEOUT.toString());
}
return args;
}

View File

@@ -1,6 +1,6 @@
{
"name": "@redis/search",
"version": "1.1.2",
"version": "1.1.3",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",