You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
44
packages/search/lib/commands/AGGREGATE_WITHCURSOR.ts
Normal file
44
packages/search/lib/commands/AGGREGATE_WITHCURSOR.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
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]
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user