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

fix graph

This commit is contained in:
Leibale
2023-07-13 14:13:23 -04:00
parent a3e813d3ac
commit 418f1f9ac8
2 changed files with 13 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
import { RedisArgument, Command, ArrayReply, BlobStringReply, NumberReply, NullReply, TuplesReply } from '@redis/client/dist/lib/RESP/types';
import { RedisArgument, ArrayReply, BlobStringReply, NumberReply, NullReply, TuplesReply, UnwrapReply, Command } from '@redis/client/dist/lib/RESP/types';
type Headers = ArrayReply<BlobStringReply>;
@@ -89,7 +89,7 @@ export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments: transformQueryArguments.bind(undefined, 'GRAPH.QUERY'),
transformReply(reply: QueryRawReply) {
transformReply(reply: UnwrapReply<QueryRawReply>) {
return reply.length === 1 ? {
headers: undefined,
data: undefined,

View File

@@ -1,4 +1,4 @@
import { RedisArgument, ArrayReply, TuplesReply, BlobStringReply, Command } from '@redis/client/dist/lib/RESP/types';
import { RedisArgument, ArrayReply, TuplesReply, BlobStringReply, UnwrapReply, Command } from '@redis/client/dist/lib/RESP/types';
type SlowLogRawReply = ArrayReply<TuplesReply<[
timestamp: BlobStringReply,
@@ -13,12 +13,15 @@ export default {
transformArguments(key: RedisArgument) {
return ['GRAPH.SLOWLOG', key];
},
transformReply(reply: SlowLogRawReply) {
return reply.map(([timestamp, command, query, took]) => ({
timestamp: Number(timestamp),
command,
query,
took: Number(took)
}));
transformReply(reply: UnwrapReply<SlowLogRawReply>) {
return reply.map(log => {
const [timestamp, command, query, took] = log as unknown as UnwrapReply<typeof log>;
return {
timestamp: Number(timestamp),
command,
query,
took: Number(took)
};
});
}
} as const satisfies Command;