You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
HSCAN NOVALUES support (v5) (#2758)
* HSCAN VALUES support (v5) * add hscanNoValuesIterator * nitpick --------- Co-authored-by: Leibale Eidelman <me@leibale.com>
This commit is contained in:
56
packages/client/lib/commands/HSCAN_NOVALUES.spec.ts
Normal file
56
packages/client/lib/commands/HSCAN_NOVALUES.spec.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import HSCAN_NOVALUES from './HSCAN_NOVALUES';
|
||||
|
||||
describe('HSCAN_NOVALUES', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('cusror only', () => {
|
||||
assert.deepEqual(
|
||||
HSCAN_NOVALUES.transformArguments('key', '0'),
|
||||
['HSCAN', 'key', '0', 'NOVALUES']
|
||||
);
|
||||
});
|
||||
|
||||
it('with MATCH', () => {
|
||||
assert.deepEqual(
|
||||
HSCAN_NOVALUES.transformArguments('key', '0', {
|
||||
MATCH: 'pattern'
|
||||
}),
|
||||
['HSCAN', 'key', '0', 'MATCH', 'pattern', 'NOVALUES']
|
||||
);
|
||||
});
|
||||
|
||||
it('with COUNT', () => {
|
||||
assert.deepEqual(
|
||||
HSCAN_NOVALUES.transformArguments('key', '0', {
|
||||
COUNT: 1
|
||||
}),
|
||||
['HSCAN', 'key', '0', 'COUNT', '1', 'NOVALUES']
|
||||
);
|
||||
});
|
||||
|
||||
it('with MATCH & COUNT', () => {
|
||||
assert.deepEqual(
|
||||
HSCAN_NOVALUES.transformArguments('key', '0', {
|
||||
MATCH: 'pattern',
|
||||
COUNT: 1
|
||||
}),
|
||||
['HSCAN', 'key', '0', 'MATCH', 'pattern', 'COUNT', '1', 'NOVALUES']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hScanNoValues', async client => {
|
||||
const [, reply] = await Promise.all([
|
||||
client.hSet('key', 'field', 'value'),
|
||||
client.hScanNoValues('key', '0')
|
||||
]);
|
||||
|
||||
assert.deepEqual(reply, {
|
||||
cursor: '0',
|
||||
fields: [
|
||||
'field',
|
||||
]
|
||||
});
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
22
packages/client/lib/commands/HSCAN_NOVALUES.ts
Normal file
22
packages/client/lib/commands/HSCAN_NOVALUES.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { RedisArgument, BlobStringReply, Command } from '../RESP/types';
|
||||
import { ScanCommonOptions, pushScanArguments } from './SCAN';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(
|
||||
key: RedisArgument,
|
||||
cursor: RedisArgument,
|
||||
options?: ScanCommonOptions
|
||||
) {
|
||||
const args = pushScanArguments(['HSCAN', key], cursor, options);
|
||||
args.push('NOVALUES');
|
||||
return args;
|
||||
},
|
||||
transformReply([cursor, fields]: [BlobStringReply, Array<BlobStringReply>]) {
|
||||
return {
|
||||
cursor,
|
||||
fields
|
||||
};
|
||||
}
|
||||
} as const satisfies Command;
|
@@ -144,6 +144,7 @@ import HRANDFIELD_COUNT_WITHVALUES from './HRANDFIELD_COUNT_WITHVALUES';
|
||||
import HRANDFIELD_COUNT from './HRANDFIELD_COUNT';
|
||||
import HRANDFIELD from './HRANDFIELD';
|
||||
import HSCAN from './HSCAN';
|
||||
import HSCAN_NOVALUES from './HSCAN_NOVALUES';
|
||||
import HSET from './HSET';
|
||||
import HSETNX from './HSETNX';
|
||||
import HSTRLEN from './HSTRLEN';
|
||||
@@ -623,6 +624,8 @@ export default {
|
||||
hRandField: HRANDFIELD,
|
||||
HSCAN,
|
||||
hScan: HSCAN,
|
||||
HSCAN_NOVALUES,
|
||||
hScanNoValues: HSCAN_NOVALUES,
|
||||
HSET,
|
||||
hSet: HSET,
|
||||
HSETNX,
|
||||
|
Reference in New Issue
Block a user