You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
35 lines
971 B
TypeScript
35 lines
971 B
TypeScript
import { CommandParser } from '@redis/client/dist/lib/client/parser';
|
|
import { RedisArgument, NumberReply, ArrayReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
|
|
import { RedisJSON, transformRedisJsonArgument } from '.';
|
|
|
|
export interface JsonArrIndexOptions {
|
|
range?: {
|
|
start: number;
|
|
stop?: number;
|
|
};
|
|
}
|
|
|
|
export default {
|
|
IS_READ_ONLY: true,
|
|
parseCommand(
|
|
parser: CommandParser,
|
|
key: RedisArgument,
|
|
path: RedisArgument,
|
|
json: RedisJSON,
|
|
options?: JsonArrIndexOptions
|
|
) {
|
|
parser.push('JSON.ARRINDEX');
|
|
parser.pushKey(key);
|
|
parser.push(path, transformRedisJsonArgument(json));
|
|
|
|
if (options?.range) {
|
|
parser.push(options.range.start.toString());
|
|
|
|
if (options.range.stop !== undefined) {
|
|
parser.push(options.range.stop.toString());
|
|
}
|
|
}
|
|
},
|
|
transformReply: undefined as unknown as () => NumberReply | ArrayReply<NumberReply | NullReply>
|
|
} as const satisfies Command;
|