diff --git a/packages/json/lib/commands/MSET.spec.ts b/packages/json/lib/commands/MSET.spec.ts index caa31b0fd2..3a8e7071e3 100644 --- a/packages/json/lib/commands/MSET.spec.ts +++ b/packages/json/lib/commands/MSET.spec.ts @@ -4,11 +4,11 @@ import { transformArguments } from './MSET'; describe('MSET', () => { testUtils.isVersionGreaterThanHook([2, 6]); - + describe('transformArguments', () => { it('transformArguments', () => { assert.deepEqual( - transformArguments([{ key: "key", path: "$", value: "json" }, { key: "key2", path: "$", value: "json2" }]), + transformArguments([{ key: 'key', path: '$', value: 'json' }, { key: 'key2', path: '$', value: 'json2' }]), ['JSON.MSET', 'key', '$', '"json"', 'key2', '$', '"json2"'] ); }); @@ -21,4 +21,4 @@ describe('MSET', () => { 'OK' ); }, GLOBAL.SERVERS.OPEN); -}); \ No newline at end of file +}); diff --git a/packages/json/lib/commands/MSET.ts b/packages/json/lib/commands/MSET.ts index 72443a6505..8c65eddb57 100644 --- a/packages/json/lib/commands/MSET.ts +++ b/packages/json/lib/commands/MSET.ts @@ -1,19 +1,16 @@ -import { RedisJSON, transformRedisJsonArgument } from '.'; +import { RedisJSON, transformRedisJsonArgument} from '.'; +import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; export const FIRST_KEY_INDEX = 1; export interface KeyPathValue { - key: string; + key: RedisCommandArgument; path: string; value: RedisJSON; } -export function transformArguments(keyPathValues: Array): Array { - if (keyPathValues.length === 0) { - throw new Error('ERR wrong number of arguments for \'MSET\' command'); - } - - const args: string[] = ['JSON.MSET']; +export function transformArguments(keyPathValues: Array): RedisCommandArguments { + const args: RedisCommandArguments = ['JSON.MSET']; keyPathValues.forEach(({ key, path, value }) => { args.push(key, path, transformRedisJsonArgument(value)); @@ -22,4 +19,4 @@ export function transformArguments(keyPathValues: Array): Array