1
0
mirror of https://github.com/redis/node-redis.git synced 2025-12-14 09:42:12 +03:00
Files
node-redis/packages/client/lib/commands/XTRIM.ts
Manuel Spigolon 7d905c0027 fix(ts): xtrim threshold accepts string (#2828)
* fix(ts): xtrim threshold accepts string

* test: check MINID with text id
2025-08-15 13:36:04 +03:00

34 lines
750 B
TypeScript

import { NumberReply, Command, RedisArgument } from '../RESP/types';
export interface XTrimOptions {
strategyModifier?: '=' | '~';
/** added in 6.2 */
LIMIT?: number;
}
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(
key: RedisArgument,
strategy: 'MAXLEN' | 'MINID',
threshold: number | string,
options?: XTrimOptions
) {
const args = ['XTRIM', key, strategy];
if (options?.strategyModifier) {
args.push(options.strategyModifier);
}
args.push(threshold.toString());
if (options?.LIMIT) {
args.push('LIMIT', options.LIMIT.toString());
}
return args;
},
transformReply: undefined as unknown as () => NumberReply
} as const satisfies Command;