1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Support RedisTimeSeries (#1757)

* Implement missing commands and add test

* Update DECRBY.spec.ts

* Small changes

* clean code

* Update MGET_WITHLABELS.ts

Use map in transformReply

Co-authored-by: leibale <leibale1998@gmail.com>
This commit is contained in:
Avital Fine
2021-12-12 14:41:44 +01:00
committed by GitHub
parent bb75b06d67
commit 7110f23369
30 changed files with 1310 additions and 47 deletions

View File

@@ -1,31 +1,26 @@
import { pushVerdictArgument, pushVerdictArguments } from '@node-redis/client/lib/commands/generic-transformers';
import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands';
import { Filter, pushFilterArgument, RawLabels, SampleRawReply, SampleReply, transformSampleReply } from '.';
export const IS_READ_ONLY = true;
interface WithLabels {
WITHLABELS: true;
export function transformArguments(filter: Filter): RedisCommandArguments {
return pushFilterArgument(['TS.MGET'], filter);
}
interface SelectedLabels {
SELECTED_LABELS: string | Array<string>;
export type MGetRawReply = Array<[
key: string,
labels: RawLabels,
sample: SampleRawReply
]>;
export interface MGetReply {
key: string,
sample: SampleReply
}
type MGetOptions = WithLabels & SelectedLabels;
export function transformArguments(filter: string, options?: MGetOptions): Array<string> {
const args = ['TS.MGET'];
if (options?.WITHLABELS) {
args.push('WITHLABELS');
} else if (options?.SELECTED_LABELS) {
pushVerdictArguments(args, options.SELECTED_LABELS);
}
args.push('FILTER', filter);
return args;
}
export function transformReply() {
export function transformReply(reply: MGetRawReply): Array<MGetReply> {
return reply.map(([key, _, sample]) => ({
key,
sample: transformSampleReply(sample)
}));
}