You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
* fix #2189 - add graph --compact support * clean code * fix graph string param escaping * fix "is not assignable to parameter of type 'GraphClientType'" * fix README
This commit is contained in:
@ -1,24 +1,26 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands/index';
|
||||
import { pushQueryArguments } from '.';
|
||||
import { pushQueryArguments, QueryOptionsBackwardCompatible } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(
|
||||
graph: RedisCommandArgument,
|
||||
query: RedisCommandArgument,
|
||||
timeout?: number
|
||||
options?: QueryOptionsBackwardCompatible,
|
||||
compact?: boolean
|
||||
): RedisCommandArguments {
|
||||
return pushQueryArguments(
|
||||
['GRAPH.QUERY'],
|
||||
graph,
|
||||
query,
|
||||
timeout
|
||||
options,
|
||||
compact
|
||||
);
|
||||
}
|
||||
|
||||
type Headers = Array<string>;
|
||||
|
||||
type Data = Array<Array<string | number | null>>;
|
||||
type Data = Array<string | number | null | Data>;
|
||||
|
||||
type Metadata = Array<string>;
|
||||
|
||||
@ -26,16 +28,26 @@ type QueryRawReply = [
|
||||
headers: Headers,
|
||||
data: Data,
|
||||
metadata: Metadata
|
||||
] | [
|
||||
metadata: Metadata
|
||||
];
|
||||
|
||||
interface QueryReply {
|
||||
headers: Headers,
|
||||
data: Data,
|
||||
metadata: Metadata
|
||||
export type QueryReply = {
|
||||
headers: undefined;
|
||||
data: undefined;
|
||||
metadata: Metadata;
|
||||
} | {
|
||||
headers: Headers;
|
||||
data: Data;
|
||||
metadata: Metadata;
|
||||
};
|
||||
|
||||
export function transformReply(reply: QueryRawReply): QueryReply {
|
||||
return {
|
||||
return reply.length === 1 ? {
|
||||
headers: undefined,
|
||||
data: undefined,
|
||||
metadata: reply[0]
|
||||
} : {
|
||||
headers: reply[0],
|
||||
data: reply[1],
|
||||
metadata: reply[2]
|
||||
|
Reference in New Issue
Block a user