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

Support JSON.MERGE Command

This commit is contained in:
shacharPash
2023-05-16 16:10:29 +03:00
parent 67d9c3c46a
commit e3ee1d2763
3 changed files with 31 additions and 0 deletions

View File

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

View File

@@ -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' | null;

View File

@@ -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,