You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
some json and search commands
This commit is contained in:
@@ -1,23 +1,34 @@
|
||||
import { RedisArgument, SimpleStringReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { RedisJSON, transformRedisJsonArgument } from '.';
|
||||
|
||||
export interface NX {
|
||||
NX: true;
|
||||
}
|
||||
|
||||
export interface XX {
|
||||
XX: true;
|
||||
export interface JsonSetOptions {
|
||||
condition?: 'NX' | 'XX';
|
||||
/**
|
||||
* @deprecated Use `{ condition: 'NX' }` instead.
|
||||
*/
|
||||
NX?: boolean;
|
||||
/**
|
||||
* @deprecated Use `{ condition: 'XX' }` instead.
|
||||
*/
|
||||
XX?: boolean;
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, path: RedisArgument, json: RedisJSON, options?: NX | XX) {
|
||||
transformArguments(
|
||||
key: RedisArgument,
|
||||
path: RedisArgument,
|
||||
json: RedisJSON,
|
||||
options?: JsonSetOptions
|
||||
) {
|
||||
const args = ['JSON.SET', key, path, transformRedisJsonArgument(json)];
|
||||
|
||||
if ((<NX>options)?.NX) {
|
||||
if (options?.condition) {
|
||||
args.push(options?.condition);
|
||||
} else if (options?.NX) {
|
||||
args.push('NX');
|
||||
} else if ((<XX>options)?.XX) {
|
||||
} else if (options?.XX) {
|
||||
args.push('XX');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user