You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
FT.CURSOR READ
This commit is contained in:
@@ -207,6 +207,7 @@ await cluster.multi()
|
|||||||
### Search
|
### Search
|
||||||
|
|
||||||
- `FT.SUGDEL`: [^boolean-to-number]
|
- `FT.SUGDEL`: [^boolean-to-number]
|
||||||
|
- `FT.CURSOR READ`: `cursor` type changed from `number` to `string` (in and out) to avoid issues when the number is bigger than `Number.MAX_SAFE_INTEGER`. See [here](https://github.com/redis/node-redis/issues/2561).
|
||||||
|
|
||||||
### Time Series
|
### Time Series
|
||||||
|
|
||||||
|
@@ -1,48 +1,3 @@
|
|||||||
// import {
|
|
||||||
// AggregateOptions,
|
|
||||||
// AggregateRawReply,
|
|
||||||
// AggregateReply,
|
|
||||||
// transformArguments as transformAggregateArguments,
|
|
||||||
// transformReply as transformAggregateReply
|
|
||||||
// } from './AGGREGATE';
|
|
||||||
|
|
||||||
// export { FIRST_KEY_INDEX, IS_READ_ONLY } from './AGGREGATE';
|
|
||||||
|
|
||||||
// interface AggregateWithCursorOptions extends AggregateOptions {
|
|
||||||
// COUNT?: number;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export function transformArguments(
|
|
||||||
// index: string,
|
|
||||||
// query: string,
|
|
||||||
// options?: AggregateWithCursorOptions
|
|
||||||
// ) {
|
|
||||||
// const args = transformAggregateArguments(index, query, options);
|
|
||||||
|
|
||||||
// args.push('WITHCURSOR');
|
|
||||||
// if (options?.COUNT) {
|
|
||||||
// args.push('COUNT', options.COUNT.toString());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return args;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// type AggregateWithCursorRawReply = [
|
|
||||||
// result: AggregateRawReply,
|
|
||||||
// cursor: number
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// interface AggregateWithCursorReply extends AggregateReply {
|
|
||||||
// cursor: number;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export function transformReply(reply: AggregateWithCursorRawReply): AggregateWithCursorReply {
|
|
||||||
// return {
|
|
||||||
// ...transformAggregateReply(reply[0]),
|
|
||||||
// cursor: reply[1]
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||||
import AGGREGATE, { FtAggregateOptions } from './AGGREGATE';
|
import AGGREGATE, { FtAggregateOptions } from './AGGREGATE';
|
||||||
|
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import { SchemaFieldTypes } from '.';
|
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './CURSOR_READ';
|
import CURSOR_READ from './CURSOR_READ';
|
||||||
|
|
||||||
describe('CURSOR READ', () => {
|
describe('FT.CURSOR READ', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('without options', () => {
|
it('without options', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('index', 0),
|
CURSOR_READ.transformArguments('index', '0'),
|
||||||
['FT.CURSOR', 'READ', 'index', '0']
|
['FT.CURSOR', 'READ', 'index', '0']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with COUNT', () => {
|
it('with COUNT', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('index', 0, { COUNT: 1 }),
|
CURSOR_READ.transformArguments('index', '0', {
|
||||||
|
COUNT: 1
|
||||||
|
}),
|
||||||
['FT.CURSOR', 'READ', 'index', '0', 'COUNT', '1']
|
['FT.CURSOR', 'READ', 'index', '0', 'COUNT', '1']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -23,9 +24,7 @@ describe('CURSOR READ', () => {
|
|||||||
testUtils.testWithClient('client.ft.cursorRead', async client => {
|
testUtils.testWithClient('client.ft.cursorRead', async client => {
|
||||||
const [, , { cursor }] = await Promise.all([
|
const [, , { cursor }] = await Promise.all([
|
||||||
client.ft.create('idx', {
|
client.ft.create('idx', {
|
||||||
field: {
|
field: 'TEXT'
|
||||||
type: SchemaFieldTypes.TEXT
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
client.hSet('key', 'field', 'value'),
|
client.hSet('key', 'field', 'value'),
|
||||||
client.ft.aggregateWithCursor('idx', '*', {
|
client.ft.aggregateWithCursor('idx', '*', {
|
||||||
@@ -38,7 +37,7 @@ describe('CURSOR READ', () => {
|
|||||||
{
|
{
|
||||||
total: 0,
|
total: 0,
|
||||||
results: [],
|
results: [],
|
||||||
cursor: 0
|
cursor: '0'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
@@ -1,30 +1,21 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands';
|
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||||
|
import AGGREGATE_WITHCURSOR from './AGGREGATE_WITHCURSOR';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export interface FtCursorReadOptions {
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
|
||||||
|
|
||||||
interface CursorReadOptions {
|
|
||||||
COUNT?: number;
|
COUNT?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transformArguments(
|
export default {
|
||||||
index: RedisCommandArgument,
|
FIRST_KEY_INDEX: undefined,
|
||||||
cursor: number,
|
IS_READ_ONLY: true,
|
||||||
options?: CursorReadOptions
|
transformArguments(index: RedisArgument, cursor: RedisArgument, options?: FtCursorReadOptions) {
|
||||||
): RedisCommandArguments {
|
const args = ['FT.CURSOR', 'READ', index, cursor];
|
||||||
const args = [
|
|
||||||
'FT.CURSOR',
|
|
||||||
'READ',
|
|
||||||
index,
|
|
||||||
cursor.toString()
|
|
||||||
];
|
|
||||||
|
|
||||||
if (options?.COUNT) {
|
if (options?.COUNT !== undefined) {
|
||||||
args.push('COUNT', options.COUNT.toString());
|
args.push('COUNT', options.COUNT.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
},
|
||||||
|
transformReply: AGGREGATE_WITHCURSOR.transformReply
|
||||||
export { transformReply } from './AGGREGATE_WITHCURSOR';
|
} as const satisfies Command;
|
||||||
|
@@ -9,7 +9,7 @@ import CONFIG_GET from './CONFIG_GET';
|
|||||||
import CONFIG_SET from './CONFIG_SET';
|
import CONFIG_SET from './CONFIG_SET';
|
||||||
import CREATE from './CREATE';
|
import CREATE from './CREATE';
|
||||||
import CURSOR_DEL from './CURSOR_DEL';
|
import CURSOR_DEL from './CURSOR_DEL';
|
||||||
// import CURSOR_READ from './CURSOR_READ';
|
import CURSOR_READ from './CURSOR_READ';
|
||||||
import DICTADD from './DICTADD';
|
import DICTADD from './DICTADD';
|
||||||
import DICTDEL from './DICTDEL';
|
import DICTDEL from './DICTDEL';
|
||||||
import DICTDUMP from './DICTDUMP';
|
import DICTDUMP from './DICTDUMP';
|
||||||
@@ -61,8 +61,8 @@ export default {
|
|||||||
create: CREATE,
|
create: CREATE,
|
||||||
CURSOR_DEL,
|
CURSOR_DEL,
|
||||||
cursorDel: CURSOR_DEL,
|
cursorDel: CURSOR_DEL,
|
||||||
// CURSOR_READ,
|
CURSOR_READ,
|
||||||
// cursorRead: CURSOR_READ,
|
cursorRead: CURSOR_READ,
|
||||||
DICTADD,
|
DICTADD,
|
||||||
dictAdd: DICTADD,
|
dictAdd: DICTADD,
|
||||||
DICTDEL,
|
DICTDEL,
|
||||||
|
Reference in New Issue
Block a user