You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-10 11:43:01 +03:00
wip
This commit is contained in:
42
packages/client/lib/commands/ZADD_INCR.ts
Normal file
42
packages/client/lib/commands/ZADD_INCR.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { RedisArgument, DoubleReply, NullReply, Command } from '../RESP/types';
|
||||
import { pushMembers } from './ZADD';
|
||||
import { ZMember, transformDoubleArgument, transformNullableDoubleReply } from './generic-transformers';
|
||||
|
||||
export interface ZAddOptions {
|
||||
condition?: 'NX' | 'XX';
|
||||
comparison?: 'LT' | 'GT';
|
||||
CH?: boolean;
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
transformArguments(
|
||||
key: RedisArgument,
|
||||
members: ZMember | Array<ZMember>,
|
||||
options?: ZAddOptions
|
||||
) {
|
||||
const args = ['ZADD', key];
|
||||
|
||||
if (options?.condition) {
|
||||
args.push(options.condition);
|
||||
}
|
||||
|
||||
if (options?.comparison) {
|
||||
args.push(options.comparison);
|
||||
}
|
||||
|
||||
if (options?.CH) {
|
||||
args.push('CH');
|
||||
}
|
||||
|
||||
args.push('INCR');
|
||||
|
||||
pushMembers(args, members);
|
||||
|
||||
return args;
|
||||
},
|
||||
transformReply: {
|
||||
2: transformNullableDoubleReply,
|
||||
3: undefined as unknown as () => DoubleReply | NullReply
|
||||
}
|
||||
} as const satisfies Command;
|
Reference in New Issue
Block a user