You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Merge branch 'master' of github.com:rowantrollope/node-redis into v5
This commit is contained in:
35
packages/json/lib/commands/MSET.spec.ts
Normal file
35
packages/json/lib/commands/MSET.spec.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { strict as assert } from 'assert';
|
||||||
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
|
import { transformArguments } from './MSET';
|
||||||
|
|
||||||
|
describe('MSET', () => {
|
||||||
|
it('transformArguments', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
transformArguments([{
|
||||||
|
key: '1',
|
||||||
|
path: '$',
|
||||||
|
value: 1
|
||||||
|
}, {
|
||||||
|
key: '2',
|
||||||
|
path: '$',
|
||||||
|
value: '2'
|
||||||
|
}]),
|
||||||
|
['JSON.MSET', '1', '$', '1', '2', '$', '"2"']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testWithClient('client.json.mSet', async client => {
|
||||||
|
assert.deepEqual(
|
||||||
|
await client.json.mSet([{
|
||||||
|
key: '1',
|
||||||
|
path: '$',
|
||||||
|
value: 1
|
||||||
|
}, {
|
||||||
|
key: '2',
|
||||||
|
path: '$',
|
||||||
|
value: '2'
|
||||||
|
}]),
|
||||||
|
'OK'
|
||||||
|
);
|
||||||
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
});
|
28
packages/json/lib/commands/MSET.ts
Normal file
28
packages/json/lib/commands/MSET.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { RedisJSON, transformRedisJsonArgument } from '.';
|
||||||
|
import { RedisCommandArgument } from '@redis/client/dist/lib/commands';
|
||||||
|
|
||||||
|
export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
|
interface JsonMSetItem {
|
||||||
|
key: RedisCommandArgument;
|
||||||
|
path: RedisCommandArgument;
|
||||||
|
value: RedisJSON;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function transformArguments(items: Array<JsonMSetItem>): Array<string> {
|
||||||
|
|
||||||
|
const args = new Array(1 + items.length * 3);
|
||||||
|
args[0] = 'JSON.MSET';
|
||||||
|
|
||||||
|
let argsIndex = 1;
|
||||||
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
const item = items[i];
|
||||||
|
args[argsIndex++] = item.key;
|
||||||
|
args[argsIndex++] = item.path;
|
||||||
|
args[argsIndex++] = transformRedisJsonArgument(item.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare function transformReply(): 'OK';
|
@@ -1,15 +1,16 @@
|
|||||||
import ARRAPPEND from './ARRAPPEND';
|
import ARRAPPEND from './ARRAPPEND';
|
||||||
import ARRINDEX from './ARRINDEX';
|
import ARRINDEX from './ARRINDEX';
|
||||||
import ARRINSERT from './ARRINSERT';
|
import ARRINSERT from './ARRINSERT';
|
||||||
import CLEAR from './CLEAR';
|
|
||||||
import ARRLEN from './ARRLEN';
|
import ARRLEN from './ARRLEN';
|
||||||
// import ARRPOP from './ARRPOP';
|
// import ARRPOP from './ARRPOP';
|
||||||
import ARRTRIM from './ARRTRIM';
|
import ARRTRIM from './ARRTRIM';
|
||||||
|
import CLEAR from './CLEAR';
|
||||||
import DEBUG_MEMORY from './DEBUG_MEMORY';
|
import DEBUG_MEMORY from './DEBUG_MEMORY';
|
||||||
import DEL from './DEL';
|
import DEL from './DEL';
|
||||||
import FORGET from './FORGET';
|
import FORGET from './FORGET';
|
||||||
// import GET from './GET';
|
// import GET from './GET';
|
||||||
// import MGET from './MGET';
|
// import MGET from './MGET';
|
||||||
|
import MSET from './MSET';
|
||||||
import NUMINCRBY from './NUMINCRBY';
|
import NUMINCRBY from './NUMINCRBY';
|
||||||
import NUMMULTBY from './NUMMULTBY';
|
import NUMMULTBY from './NUMMULTBY';
|
||||||
import OBJKEYS from './OBJKEYS';
|
import OBJKEYS from './OBJKEYS';
|
||||||
@@ -28,14 +29,14 @@ export default {
|
|||||||
arrIndex: ARRINDEX,
|
arrIndex: ARRINDEX,
|
||||||
ARRINSERT,
|
ARRINSERT,
|
||||||
arrInsert: ARRINSERT,
|
arrInsert: ARRINSERT,
|
||||||
CLEAR,
|
|
||||||
clear: CLEAR,
|
|
||||||
ARRLEN,
|
ARRLEN,
|
||||||
arrLen: ARRLEN,
|
arrLen: ARRLEN,
|
||||||
// ARRPOP,
|
// ARRPOP,
|
||||||
// arrPop: ARRPOP,
|
// arrPop: ARRPOP,
|
||||||
ARRTRIM,
|
ARRTRIM,
|
||||||
arrTrim: ARRTRIM,
|
arrTrim: ARRTRIM,
|
||||||
|
CLEAR,
|
||||||
|
clear: CLEAR,
|
||||||
DEBUG_MEMORY,
|
DEBUG_MEMORY,
|
||||||
debugMemory: DEBUG_MEMORY,
|
debugMemory: DEBUG_MEMORY,
|
||||||
DEL,
|
DEL,
|
||||||
@@ -46,6 +47,8 @@ export default {
|
|||||||
// get: GET,
|
// get: GET,
|
||||||
// MGET,
|
// MGET,
|
||||||
// mGet: MGET,
|
// mGet: MGET,
|
||||||
|
MSET,
|
||||||
|
mSet: MSET,
|
||||||
NUMINCRBY,
|
NUMINCRBY,
|
||||||
numIncrBy: NUMINCRBY,
|
numIncrBy: NUMINCRBY,
|
||||||
NUMMULTBY,
|
NUMMULTBY,
|
||||||
|
Reference in New Issue
Block a user