diff --git a/packages/json/lib/commands/MERGE.spec.ts b/packages/json/lib/commands/MERGE.spec.ts new file mode 100644 index 0000000000..650fb4e873 --- /dev/null +++ b/packages/json/lib/commands/MERGE.spec.ts @@ -0,0 +1,19 @@ +import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; +import { transformArguments } from './MERGE'; + +describe('MERGE', () => { + 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); +}); \ No newline at end of file diff --git a/packages/json/lib/commands/MERGE.ts b/packages/json/lib/commands/MERGE.ts new file mode 100644 index 0000000000..1aada1f520 --- /dev/null +++ b/packages/json/lib/commands/MERGE.ts @@ -0,0 +1,9 @@ +import { RedisJSON, transformRedisJsonArgument } from '.'; + +export const FIRST_KEY_INDEX = 1; + +export function transformArguments(key: string, path: string, json: RedisJSON): Array { + return ['JSON.MERGE', key, path, transformRedisJsonArgument(json)]; +} + +export declare function transformReply(): 'OK' | null; \ No newline at end of file diff --git a/packages/json/lib/commands/index.ts b/packages/json/lib/commands/index.ts index efcf156b84..cc9dc824ca 100644 --- a/packages/json/lib/commands/index.ts +++ b/packages/json/lib/commands/index.ts @@ -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'; @@ -40,6 +41,8 @@ export default { forget: FORGET, GET, get: GET, + MERGE, + merge: MERGE, MGET, mGet: MGET, NUMINCRBY,