| 1 |
import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; |
| 2 |
import { Filter, pushFilterArgument, pushLatestArgument, RawLabels, SampleRawReply, SampleReply, transformSampleReply } from '.'; |
| 3 |
|
| 4 |
export const IS_READ_ONLY = true; |
| 5 |
|
| 6 |
export interface MGetOptions { |
| 7 |
LATEST?: boolean; |
| 8 |
} |
| 9 |
|
| 10 |
export function transformArguments(filter: Filter, options?: MGetOptions): RedisCommandArguments { |
| 11 |
const args = pushLatestArgument(['TS.MGET'], options?.LATEST); |
| 12 |
return pushFilterArgument(args, filter); |
| 13 |
} |
| 14 |
|
| 15 |
export type MGetRawReply = Array<[ |
| 16 |
key: string, |
| 17 |
labels: RawLabels, |
| 18 |
sample: SampleRawReply |
| 19 |
]>; |
| 20 |
|
| 21 |
export interface MGetReply { |
| 22 |
key: string, |
| 23 |
sample: SampleReply |
| 24 |
} |
| 25 |
|
| 26 |
export function transformReply(reply: MGetRawReply): Array<MGetReply> { |
| 27 |
return reply.map(([key, _, sample]) => ({ |
| 28 |
key, |
| 29 |
sample: transformSampleReply(sample) |
| 30 |
})); |
| 31 |
} |