| 1 |
import { |
| 2 |
SelectedLabels, |
| 3 |
pushWithLabelsArgument, |
| 4 |
Labels, |
| 5 |
transformLablesReply, |
| 6 |
transformSampleReply, |
| 7 |
Filter, |
| 8 |
pushFilterArgument |
| 9 |
} from '.'; |
| 10 |
import { MGetOptions, MGetRawReply, MGetReply } from './MGET'; |
| 11 |
import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; |
| 12 |
|
| 13 |
export const IS_READ_ONLY = true; |
| 14 |
|
| 15 |
interface MGetWithLabelsOptions extends MGetOptions { |
| 16 |
SELECTED_LABELS?: SelectedLabels; |
| 17 |
} |
| 18 |
|
| 19 |
export function transformArguments( |
| 20 |
filter: Filter, |
| 21 |
options?: MGetWithLabelsOptions |
| 22 |
): RedisCommandArguments { |
| 23 |
const args = pushWithLabelsArgument(['TS.MGET'], options?.SELECTED_LABELS); |
| 24 |
return pushFilterArgument(args, filter); |
| 25 |
} |
| 26 |
|
| 27 |
export interface MGetWithLabelsReply extends MGetReply { |
| 28 |
labels: Labels; |
| 29 |
}; |
| 30 |
|
| 31 |
export function transformReply(reply: MGetRawReply): Array<MGetWithLabelsReply> { |
| 32 |
return reply.map(([key, labels, sample]) => ({ |
| 33 |
key, |
| 34 |
labels: transformLablesReply(labels), |
| 35 |
sample: transformSampleReply(sample) |
| 36 |
})); |
| 37 |
} |