1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-10 11:43:01 +03:00
Files
node-redis/packages/time-series/lib/commands/GET.ts
2023-07-05 14:19:38 -04:00

31 lines
857 B
TypeScript

import { RedisArgument, TuplesReply, NumberReply, DoubleReply, Resp2Reply, Command } from '@redis/client/dist/lib/RESP/types';
import { pushLatestArgument } from '.';
export interface TsGetOptions {
LATEST?: boolean;
}
export type TsGetReply = TuplesReply<[]> | TuplesReply<[NumberReply, DoubleReply]>;
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: true,
transformArguments(key: RedisArgument, options?: TsGetOptions) {
return pushLatestArgument(['TS.GET', key], options?.LATEST);
},
transformReply: {
2(reply: Resp2Reply<TsGetReply>) {
return reply.length === 0 ? null : {
timestamp: reply[0],
value: Number(reply[1])
};
},
3(reply: TsGetReply) {
return reply.length === 0 ? null : {
timestamp: reply[0],
value: reply[1]
};
}
}
} as const satisfies Command;