You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-03 04:01:40 +03:00
66 lines
1.3 KiB
TypeScript
66 lines
1.3 KiB
TypeScript
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
|
import { AuthOptions } from './AUTH';
|
|
|
|
interface MigrateOptions {
|
|
COPY?: true;
|
|
REPLACE?: true;
|
|
AUTH?: AuthOptions;
|
|
}
|
|
|
|
export function transformArguments(
|
|
host: RedisCommandArgument,
|
|
port: number,
|
|
key: RedisCommandArgument | Array<RedisCommandArgument>,
|
|
destinationDb: number,
|
|
timeout: number,
|
|
options?: MigrateOptions
|
|
): RedisCommandArguments {
|
|
const args = ['MIGRATE', host, port.toString()],
|
|
isKeyArray = Array.isArray(key);
|
|
|
|
if (isKeyArray) {
|
|
args.push('""');
|
|
} else {
|
|
args.push(key);
|
|
}
|
|
|
|
args.push(
|
|
destinationDb.toString(),
|
|
timeout.toString()
|
|
);
|
|
|
|
if (options?.COPY) {
|
|
args.push('COPY');
|
|
}
|
|
|
|
if (options?.REPLACE) {
|
|
args.push('REPLACE');
|
|
}
|
|
|
|
if (options?.AUTH) {
|
|
if (options.AUTH.username) {
|
|
args.push(
|
|
'AUTH2',
|
|
options.AUTH.username,
|
|
options.AUTH.password
|
|
);
|
|
} else {
|
|
args.push(
|
|
'AUTH',
|
|
options.AUTH.password
|
|
);
|
|
}
|
|
}
|
|
|
|
if (isKeyArray) {
|
|
args.push(
|
|
'KEYS',
|
|
...key
|
|
);
|
|
}
|
|
|
|
return args;
|
|
}
|
|
|
|
export declare function transformReply(): string;
|