1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00
This commit is contained in:
Leibale
2023-07-27 11:23:34 -04:00
parent 61c3e8b95b
commit ff07bbf3d3
25 changed files with 745 additions and 630 deletions

View File

@@ -1,31 +1,31 @@
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
import { Filter, pushFilterArgument, pushLatestArgument, RawLabels, SampleRawReply, SampleReply, transformSampleReply } from '.';
import { CommandArguments, Command } from '@redis/client/dist/lib/RESP/types';
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
export const IS_READ_ONLY = true;
export interface MGetOptions {
LATEST?: boolean;
export interface TsMGetOptions {
LATEST?: boolean;
}
export function transformArguments(filter: Filter, options?: MGetOptions): RedisCommandArguments {
export function pushLatestArgument(args: CommandArguments, latest?: boolean) {
if (latest) {
args.push('LATEST');
}
return args;
}
export function pushFilterArgument(args: CommandArguments, filter: RedisVariadicArgument) {
args.push('FILTER');
return pushVariadicArguments(args, filter);
}
export default {
FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true,
transformArguments(filter: RedisVariadicArgument, options?: TsMGetOptions) {
const args = pushLatestArgument(['TS.MGET'], options?.LATEST);
return pushFilterArgument(args, filter);
}
export type MGetRawReply = Array<[
key: string,
labels: RawLabels,
sample: SampleRawReply
]>;
export interface MGetReply {
key: string,
sample: SampleReply
}
export function transformReply(reply: MGetRawReply): Array<MGetReply> {
return reply.map(([key, _, sample]) => ({
key,
sample: transformSampleReply(sample)
}));
}
},
// TODO
// transformSampleReply
transformReply: undefined as unknown as () => any
} as const satisfies Command;