You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
* Added MSET command MSET command added. Requires all keys to have the same JSON Path, which might fit most use cases, but is a limitation. Optionally we could make the path an array as well to support all use cases. * change JSON.MSET signature, add to json command object, fix tests * its `item.value`, not `item.json`.. * Update MSET.ts Removed unused RedisCommandArguments --------- Co-authored-by: Leibale Eidelman <me@leibale.com>
29 lines
760 B
TypeScript
29 lines
760 B
TypeScript
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';
|