You've already forked node-redis
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:
@@ -8,7 +8,15 @@ describe('MSET', () => {
|
|||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
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"']
|
['JSON.MSET', 'key', '$', '"json"', 'key2', '$', '"json2"']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -5,16 +5,16 @@ export const FIRST_KEY_INDEX = 1;
|
|||||||
|
|
||||||
export interface KeyPathValue {
|
export interface KeyPathValue {
|
||||||
key: RedisCommandArgument;
|
key: RedisCommandArgument;
|
||||||
path: string;
|
path: RedisCommandArgument;
|
||||||
value: RedisJSON;
|
value: RedisJSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transformArguments(keyPathValues: Array<KeyPathValue>): RedisCommandArguments {
|
export function transformArguments(keyPathValues: Array<KeyPathValue>): RedisCommandArguments {
|
||||||
const args: RedisCommandArguments = ['JSON.MSET'];
|
const args: RedisCommandArguments = ['JSON.MSET'];
|
||||||
|
|
||||||
keyPathValues.forEach(({ key, path, value }) => {
|
for (const { key, path, value } of keyPathValues) {
|
||||||
args.push(key, path, transformRedisJsonArgument(value));
|
args.push(key, path, transformRedisJsonArgument(value));
|
||||||
});
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user