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

fixes after code review

This commit is contained in:
shacharPash
2023-05-21 14:49:06 +03:00
parent 319af5b566
commit 0df771fc99
2 changed files with 12 additions and 4 deletions

View File

@@ -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"']
);
});

View File

@@ -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<KeyPathValue>): 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;
}