Skip to content

Commit ab34898

Browse files
committed
FT.CONFIG GET
1 parent 643e086 commit ab34898

File tree

3 files changed

+43
-23
lines changed

3 files changed

+43
-23
lines changed
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
3-
import { transformArguments } from './CONFIG_GET';
3+
import CONFIG_GET from './CONFIG_GET';
44

5-
describe('CONFIG GET', () => {
6-
it('transformArguments', () => {
7-
assert.deepEqual(
8-
transformArguments('TIMEOUT'),
9-
['FT.CONFIG', 'GET', 'TIMEOUT']
10-
);
11-
});
5+
describe('FT.CONFIG GET', () => {
6+
it('transformArguments', () => {
7+
assert.deepEqual(
8+
CONFIG_GET.transformArguments('TIMEOUT'),
9+
['FT.CONFIG', 'GET', 'TIMEOUT']
10+
);
11+
});
1212

13-
testUtils.testWithClient('client.ft.configGet', async client => {
14-
assert.deepEqual(
15-
await client.ft.configGet('TIMEOUT'),
16-
Object.create(null, {
17-
TIMEOUT: {
18-
value: '500',
19-
configurable: true,
20-
enumerable: true
21-
}
22-
})
23-
);
24-
}, GLOBAL.SERVERS.OPEN);
13+
testUtils.testWithClient('client.ft.configGet', async client => {
14+
assert.deepEqual(
15+
await client.ft.configGet('TIMEOUT'),
16+
Object.create(null, {
17+
TIMEOUT: {
18+
value: '500',
19+
configurable: true,
20+
enumerable: true
21+
}
22+
})
23+
);
24+
}, GLOBAL.SERVERS.OPEN);
2525
});

packages/search/lib/commands/CONFIG_GET.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
import { ArrayReply, TuplesReply, BlobStringReply, NullReply, UnwrapReply, Command } from '@redis/client/dist/lib/RESP/types';
2+
3+
export default {
4+
FIRST_KEY_INDEX: undefined,
5+
IS_READ_ONLY: true,
6+
transformArguments(option: string) {
7+
return ['FT.CONFIG', 'GET', option];
8+
},
9+
transformReply(reply: UnwrapReply<ArrayReply<TuplesReply<[BlobStringReply, BlobStringReply | NullReply]>>>) {
10+
const transformedReply: Record<string, BlobStringReply | NullReply> = Object.create(null);
11+
for (const item of reply) {
12+
const [key, value] = item as unknown as UnwrapReply<typeof item>;
13+
transformedReply[key.toString()] = value;
14+
}
15+
16+
return transformedReply;
17+
}
18+
} as const satisfies Command;
19+
20+
121
export function transformArguments(option: string) {
222
return ['FT.CONFIG', 'GET', option];
323
}

packages/search/lib/commands/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import ALTER from './ALTER';
55
import ALIASADD from './ALIASADD';
66
import ALIASDEL from './ALIASDEL';
77
import ALIASUPDATE from './ALIASUPDATE';
8-
// import CONFIG_GET from './CONFIG_GET';
8+
import CONFIG_GET from './CONFIG_GET';
99
import CONFIG_SET from './CONFIG_SET';
1010
import CREATE from './CREATE';
1111
import CURSOR_DEL from './CURSOR_DEL';
@@ -51,8 +51,8 @@ export default {
5151
aliasDel: ALIASDEL,
5252
ALIASUPDATE,
5353
aliasUpdate: ALIASUPDATE,
54-
// CONFIG_GET,
55-
// configGet: CONFIG_GET,
54+
CONFIG_GET,
55+
configGet: CONFIG_GET,
5656
CONFIG_SET,
5757
configSet: CONFIG_SET,
5858
CREATE,

0 commit comments

Comments
 (0)