You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
some json and search commands
This commit is contained in:
@@ -1,37 +1,35 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './ALTER';
|
||||
import { SchemaFieldTypes } from '.';
|
||||
import ALTER from './ALTER';
|
||||
import { SCHEMA_FIELD_TYPE } from './CREATE';
|
||||
|
||||
describe('ALTER', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('with NOINDEX', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('index', {
|
||||
field: {
|
||||
type: SchemaFieldTypes.TEXT,
|
||||
NOINDEX: true,
|
||||
SORTABLE: 'UNF',
|
||||
AS: 'text'
|
||||
}
|
||||
}),
|
||||
['FT.ALTER', 'index', 'SCHEMA', 'ADD', 'field', 'AS', 'text', 'TEXT', 'SORTABLE', 'UNF', 'NOINDEX']
|
||||
);
|
||||
});
|
||||
describe('FT.ALTER', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('with NOINDEX', () => {
|
||||
assert.deepEqual(
|
||||
ALTER.transformArguments('index', {
|
||||
field: {
|
||||
type: SCHEMA_FIELD_TYPE.TEXT,
|
||||
NOINDEX: true,
|
||||
SORTABLE: 'UNF',
|
||||
AS: 'text'
|
||||
}
|
||||
}),
|
||||
['FT.ALTER', 'index', 'SCHEMA', 'ADD', 'field', 'AS', 'text', 'TEXT', 'SORTABLE', 'UNF', 'NOINDEX']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.ft.create', async client => {
|
||||
await Promise.all([
|
||||
client.ft.create('index', {
|
||||
title: SchemaFieldTypes.TEXT
|
||||
}),
|
||||
]);
|
||||
testUtils.testWithClient('client.ft.create', async client => {
|
||||
const [, reply] = await Promise.all([
|
||||
client.ft.create('index', {
|
||||
title: SCHEMA_FIELD_TYPE.TEXT
|
||||
}),
|
||||
client.ft.alter('index', {
|
||||
body: SCHEMA_FIELD_TYPE.TEXT
|
||||
})
|
||||
]);
|
||||
|
||||
assert.equal(
|
||||
await client.ft.alter('index', {
|
||||
body: SchemaFieldTypes.TEXT
|
||||
}),
|
||||
'OK'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
assert.equal(reply, 'OK');
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,10 +1,13 @@
|
||||
import { RediSearchSchema, pushSchema } from '.';
|
||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { RediSearchSchema, pushSchema } from './CREATE';
|
||||
|
||||
export function transformArguments(index: string, schema: RediSearchSchema): Array<string> {
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(index: RedisArgument, schema: RediSearchSchema) {
|
||||
const args = ['FT.ALTER', index, 'SCHEMA', 'ADD'];
|
||||
pushSchema(args, schema);
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export declare function transformReply(): 'OK';
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,12 +1,19 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './CONFIG_SET';
|
||||
import CONFIG_SET from './CONFIG_SET';
|
||||
|
||||
describe('CONFIG SET', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('TIMEOUT', '500'),
|
||||
['FT.CONFIG', 'SET', 'TIMEOUT', '500']
|
||||
);
|
||||
});
|
||||
describe('FT.CONFIG SET', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
CONFIG_SET.transformArguments('TIMEOUT', '500'),
|
||||
['FT.CONFIG', 'SET', 'TIMEOUT', '500']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.ft.configSet', async client => {
|
||||
assert.deepEqual(
|
||||
await client.ft.configSet('TIMEOUT', '500'),
|
||||
'OK'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,5 +1,14 @@
|
||||
export function transformArguments(option: string, value: string): Array<string> {
|
||||
return ['FT.CONFIG', 'SET', option, value];
|
||||
}
|
||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
|
||||
export declare function transformReply(): 'OK';
|
||||
// using `string & {}` to avoid TS widening the type to `string`
|
||||
// TODO
|
||||
type FtConfigProperties = 'a' | 'b' | (string & {}) | Buffer;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(property: FtConfigProperties, value: RedisArgument) {
|
||||
return ['FT.CONFIG', 'SET', property, value];
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,12 +1,12 @@
|
||||
import _LIST from './_LIST';
|
||||
// import ALTER from './ALTER';
|
||||
import ALTER from './ALTER';
|
||||
// import AGGREGATE_WITHCURSOR from './AGGREGATE_WITHCURSOR';
|
||||
// import AGGREGATE from './AGGREGATE';
|
||||
import ALIASADD from './ALIASADD';
|
||||
import ALIASDEL from './ALIASDEL';
|
||||
import ALIASUPDATE from './ALIASUPDATE';
|
||||
// import CONFIG_GET from './CONFIG_GET';
|
||||
// import CONFIG_SET from './CONFIG_SET';
|
||||
import CONFIG_SET from './CONFIG_SET';
|
||||
import CREATE from './CREATE';
|
||||
import CURSOR_DEL from './CURSOR_DEL';
|
||||
// import CURSOR_READ from './CURSOR_READ';
|
||||
@@ -39,8 +39,8 @@ import { CommandArguments } from '@redis/client/dist/lib/RESP/types';
|
||||
export default {
|
||||
_LIST,
|
||||
_list: _LIST,
|
||||
// ALTER,
|
||||
// alter: ALTER,
|
||||
ALTER,
|
||||
alter: ALTER,
|
||||
// AGGREGATE_WITHCURSOR,
|
||||
// aggregateWithCursor: AGGREGATE_WITHCURSOR,
|
||||
// AGGREGATE,
|
||||
@@ -53,8 +53,8 @@ export default {
|
||||
aliasUpdate: ALIASUPDATE,
|
||||
// CONFIG_GET,
|
||||
// configGet: CONFIG_GET,
|
||||
// CONFIG_SET,
|
||||
// configSet: CONFIG_SET,
|
||||
CONFIG_SET,
|
||||
configSet: CONFIG_SET,
|
||||
CREATE,
|
||||
create: CREATE,
|
||||
CURSOR_DEL,
|
||||
|
Reference in New Issue
Block a user