You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-12-11 09:22:35 +03:00
* (docs) bloom: add jsdocs for all commands * (docs) json: add jsdocs * (docs) search: add jsdocs for all commands * (docs) jsdocs for std commands * (docs) jsdoc comments to time series commands
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { CommandParser } from '@redis/client/dist/lib/client/parser';
|
|
import { RedisArgument, Command, ReplyUnion, NumberReply } from '@redis/client/dist/lib/RESP/types';
|
|
import AGGREGATE, { AggregateRawReply, AggregateReply, FtAggregateOptions } from './AGGREGATE';
|
|
|
|
export interface FtAggregateWithCursorOptions extends FtAggregateOptions {
|
|
COUNT?: number;
|
|
MAXIDLE?: number;
|
|
}
|
|
|
|
|
|
type AggregateWithCursorRawReply = [
|
|
result: AggregateRawReply,
|
|
cursor: NumberReply
|
|
];
|
|
|
|
export interface AggregateWithCursorReply extends AggregateReply {
|
|
cursor: NumberReply;
|
|
}
|
|
|
|
export default {
|
|
IS_READ_ONLY: AGGREGATE.IS_READ_ONLY,
|
|
/**
|
|
* Performs an aggregation with a cursor for retrieving large result sets.
|
|
* @param parser - The command parser
|
|
* @param index - Name of the index to query
|
|
* @param query - The aggregation query
|
|
* @param options - Optional parameters:
|
|
* - All options supported by FT.AGGREGATE
|
|
* - COUNT: Number of results to return per cursor fetch
|
|
* - MAXIDLE: Maximum idle time for cursor in milliseconds
|
|
*/
|
|
parseCommand(parser: CommandParser, index: RedisArgument, query: RedisArgument, options?: FtAggregateWithCursorOptions) {
|
|
AGGREGATE.parseCommand(parser, index, query, options);
|
|
parser.push('WITHCURSOR');
|
|
|
|
if (options?.COUNT !== undefined) {
|
|
parser.push('COUNT', options.COUNT.toString());
|
|
}
|
|
|
|
if(options?.MAXIDLE !== undefined) {
|
|
parser.push('MAXIDLE', options.MAXIDLE.toString());
|
|
}
|
|
},
|
|
transformReply: {
|
|
2: (reply: AggregateWithCursorRawReply): AggregateWithCursorReply => {
|
|
return {
|
|
...AGGREGATE.transformReply[2](reply[0]),
|
|
cursor: reply[1]
|
|
};
|
|
},
|
|
3: undefined as unknown as () => ReplyUnion
|
|
},
|
|
unstableResp3: true
|
|
} as const satisfies Command;
|