From 0df771fc991a06a9d76512792cb644433be4696d Mon Sep 17 00:00:00 2001 From: shacharPash Date: Sun, 21 May 2023 14:49:06 +0300 Subject: [PATCH] fixes after code review --- packages/json/lib/commands/MSET.spec.ts | 10 +++++++++- packages/json/lib/commands/MSET.ts | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/json/lib/commands/MSET.spec.ts b/packages/json/lib/commands/MSET.spec.ts index 3a8e7071e3..b271949dd9 100644 --- a/packages/json/lib/commands/MSET.spec.ts +++ b/packages/json/lib/commands/MSET.spec.ts @@ -8,7 +8,15 @@ describe('MSET', () => { 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"'] ); }); diff --git a/packages/json/lib/commands/MSET.ts b/packages/json/lib/commands/MSET.ts index 8c65eddb57..b3902b9d20 100644 --- a/packages/json/lib/commands/MSET.ts +++ b/packages/json/lib/commands/MSET.ts @@ -5,16 +5,16 @@ export const FIRST_KEY_INDEX = 1; export interface KeyPathValue { key: RedisCommandArgument; - path: string; + path: RedisCommandArgument; value: RedisJSON; } export function transformArguments(keyPathValues: Array): RedisCommandArguments { const args: RedisCommandArguments = ['JSON.MSET']; - keyPathValues.forEach(({ key, path, value }) => { + for (const { key, path, value } of keyPathValues) { args.push(key, path, transformRedisJsonArgument(value)); - }); + } return args; }