You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
WIP
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user