Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/json/lib/commands/MERGE.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './MERGE';

describe('MERGE', () => {
testUtils.isVersionGreaterThanHook([2, 6]);

it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', '$', 1),
['JSON.MERGE', 'key', '$', '1']
);
});

testUtils.testWithClient('client.json.merge', async client => {
assert.equal(
await client.json.merge('key', '$', 'json'),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
});
9 changes: 9 additions & 0 deletions packages/json/lib/commands/MERGE.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { RedisJSON, transformRedisJsonArgument } from '.';

export const FIRST_KEY_INDEX = 1;

export function transformArguments(key: string, path: string, json: RedisJSON): Array<string> {
return ['JSON.MERGE', key, path, transformRedisJsonArgument(json)];
}

export declare function transformReply(): 'OK';
3 changes: 3 additions & 0 deletions packages/json/lib/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as DEL from './DEL';
import * as FORGET from './FORGET';
import * as GET from './GET';
import * as MGET from './MGET';
import * as MERGE from './MERGE';
import * as NUMINCRBY from './NUMINCRBY';
import * as NUMMULTBY from './NUMMULTBY';
import * as OBJKEYS from './OBJKEYS';
Expand Down Expand Up @@ -40,6 +41,8 @@ export default {
forget: FORGET,
GET,
get: GET,
MERGE,
merge: MERGE,
MGET,
mGet: MGET,
NUMINCRBY,
Expand Down
3 changes: 2 additions & 1 deletion packages/json/lib/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import RedisJSON from '.';

export default new TestUtils({
dockerImageName: 'redislabs/rejson',
dockerImageVersionArgument: 'rejson-version'
dockerImageVersionArgument: 'rejson-version',
defaultDockerVersion: 'edge'
});

export const GLOBAL = {
Expand Down