1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

fix XSETID

This commit is contained in:
dovi
2023-05-02 16:06:14 -04:00
parent 449d9c40ae
commit afa394e35d
4 changed files with 71 additions and 24 deletions

View File

@@ -0,0 +1,42 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import XSETID from './XSETID';
describe('XSETID', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
XSETID.transformArguments('key', '0-0'),
['XSETID', 'key', '0-0']
);
});
it('with ENTRIESADDED', () => {
assert.deepEqual(
XSETID.transformArguments('key', '0-0', {
ENTRIESADDED: 1
}),
['XSETID', 'key', '0-0', 'ENTRIESADDED', '1']
);
});
it('with MAXDELETEDID', () => {
assert.deepEqual(
XSETID.transformArguments('key', '0-0', {
MAXDELETEDID: '1-1'
}),
['XSETID', 'key', '0-0', 'MAXDELETEDID', '1-1']
);
});
});
testUtils.testAll('xSetId', async client => {
assert.deepEqual(
await client.xSetId('key', '0-0'),
[]
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,28 +1,29 @@
// import { RedisCommandArgument, RedisCommandArguments } from '.'; import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
export interface XSetIdOptions {
ENTRIESADDED?: number;
MAXDELETEDID?: RedisArgument;
}
// export const FIRST_KEY_INDEX = 1; export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(
key: RedisArgument,
lastId: RedisArgument,
options?: XSetIdOptions
) {
const args = ['XSETID', key, lastId];
// interface XSetIdOptions { if (options?.ENTRIESADDED) {
// ENTRIESADDED?: number; args.push('ENTRIESADDED', options.ENTRIESADDED.toString());
// MAXDELETEDID?: RedisCommandArgument; }
// }
// export function transformArguments( if (options?.MAXDELETEDID) {
// key: RedisCommandArgument, args.push('MAXDELETEDID', options.MAXDELETEDID);
// lastId: RedisCommandArgument, }
// options?: XSetIdOptions
// ): RedisCommandArguments {
// const args = ['XSETID', key, lastId];
// if (options?.ENTRIESADDED) { return args;
// args.push('ENTRIESADDED', options.ENTRIESADDED.toString()); },
// } transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
} as const satisfies Command;
// if (options?.MAXDELETEDID) {
// args.push('MAXDELETEDID', options.MAXDELETEDID);
// }
// return args;
// }
// export declare function transformReply(): 'OK';

View File

@@ -145,6 +145,7 @@ import XACK from './XACK';
import XADD_NOMKSTREAM from './XADD_NOMKSTREAM'; import XADD_NOMKSTREAM from './XADD_NOMKSTREAM';
import XADD from './XADD'; import XADD from './XADD';
import XDEL from './XDEL'; import XDEL from './XDEL';
import XSETID from './XSETID';
import XTRIM from './XTRIM'; import XTRIM from './XTRIM';
import XLEN from './XLEN'; import XLEN from './XLEN';
import ZADD from './ZADD'; import ZADD from './ZADD';
@@ -467,6 +468,8 @@ export default {
xAdd: XADD, xAdd: XADD,
XDEL, XDEL,
xDel: XDEL, xDel: XDEL,
XSETID,
xSetId: XSETID,
XTRIM, XTRIM,
xTrim: XTRIM, xTrim: XTRIM,
XLEN, XLEN,

View File

@@ -1,5 +1,6 @@
# return type # return type \ missing documentation
- `XAUTOCLAIM` - `XAUTOCLAIM`
- `XSETID`
# create commands # create commands