You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
more commands
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './DICTADD';
|
||||
import DICTADD from './DICTADD';
|
||||
|
||||
describe('DICTADD', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('dictionary', 'term'),
|
||||
['FT.DICTADD', 'dictionary', 'term']
|
||||
);
|
||||
});
|
||||
|
||||
it('Array', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('dictionary', ['1', '2']),
|
||||
['FT.DICTADD', 'dictionary', '1', '2']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
DICTADD.transformArguments('dictionary', 'term'),
|
||||
['FT.DICTADD', 'dictionary', 'term']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.ft.dictAdd', async client => {
|
||||
assert.equal(
|
||||
await client.ft.dictAdd('dictionary', 'term'),
|
||||
1
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
it('Array', () => {
|
||||
assert.deepEqual(
|
||||
DICTADD.transformArguments('dictionary', ['1', '2']),
|
||||
['FT.DICTADD', 'dictionary', '1', '2']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.ft.dictAdd', async client => {
|
||||
assert.equal(
|
||||
await client.ft.dictAdd('dictionary', 'term'),
|
||||
1
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,8 +1,11 @@
|
||||
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
|
||||
import { pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { pushVariadicArguments, RedisVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
|
||||
export function transformArguments(dictionary: string, term: string | Array<string>): RedisCommandArguments {
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(dictionary: RedisArgument, term: RedisVariadicArgument) {
|
||||
return pushVariadicArguments(['FT.DICTADD', dictionary], term);
|
||||
}
|
||||
|
||||
export declare function transformReply(): number;
|
||||
},
|
||||
transformReply: undefined as unknown as () => NumberReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,28 +1,28 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './DICTDEL';
|
||||
import DICTDEL from './DICTDEL';
|
||||
|
||||
describe('DICTDEL', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('dictionary', 'term'),
|
||||
['FT.DICTDEL', 'dictionary', 'term']
|
||||
);
|
||||
});
|
||||
|
||||
it('Array', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('dictionary', ['1', '2']),
|
||||
['FT.DICTDEL', 'dictionary', '1', '2']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
DICTDEL.transformArguments('dictionary', 'term'),
|
||||
['FT.DICTDEL', 'dictionary', 'term']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.ft.dictDel', async client => {
|
||||
assert.equal(
|
||||
await client.ft.dictDel('dictionary', 'term'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
it('Array', () => {
|
||||
assert.deepEqual(
|
||||
DICTDEL.transformArguments('dictionary', ['1', '2']),
|
||||
['FT.DICTDEL', 'dictionary', '1', '2']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.ft.dictDel', async client => {
|
||||
assert.equal(
|
||||
await client.ft.dictDel('dictionary', 'term'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,8 +1,11 @@
|
||||
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
|
||||
import { pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { pushVariadicArguments, RedisVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
|
||||
export function transformArguments(dictionary: string, term: string | Array<string>): RedisCommandArguments {
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(dictionary: RedisArgument, term: RedisVariadicArgument) {
|
||||
return pushVariadicArguments(['FT.DICTDEL', dictionary], term);
|
||||
}
|
||||
|
||||
export declare function transformReply(): number;
|
||||
},
|
||||
transformReply: undefined as unknown as () => NumberReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,33 +1,33 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { transformArguments } from './EXPLAIN';
|
||||
import EXPLAIN from './EXPLAIN';
|
||||
|
||||
describe('EXPLAIN', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('index', '*'),
|
||||
['FT.EXPLAIN', 'index', '*']
|
||||
);
|
||||
});
|
||||
|
||||
it('with PARAMS', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('index', '*', {
|
||||
PARAMS: {
|
||||
param: 'value'
|
||||
}
|
||||
}),
|
||||
['FT.EXPLAIN', 'index', '*', 'PARAMS', '2', 'param', 'value']
|
||||
);
|
||||
});
|
||||
|
||||
it('with DIALECT', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('index', '*', {
|
||||
DIALECT: 1
|
||||
}),
|
||||
['FT.EXPLAIN', 'index', '*', 'DIALECT', '1']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
EXPLAIN.transformArguments('index', '*'),
|
||||
['FT.EXPLAIN', 'index', '*']
|
||||
);
|
||||
});
|
||||
|
||||
it('with PARAMS', () => {
|
||||
assert.deepEqual(
|
||||
EXPLAIN.transformArguments('index', '*', {
|
||||
PARAMS: {
|
||||
param: 'value'
|
||||
}
|
||||
}),
|
||||
['FT.EXPLAIN', 'index', '*', 'PARAMS', '2', 'param', 'value']
|
||||
);
|
||||
});
|
||||
|
||||
it('with DIALECT', () => {
|
||||
assert.deepEqual(
|
||||
EXPLAIN.transformArguments('index', '*', {
|
||||
DIALECT: 1
|
||||
}),
|
||||
['FT.EXPLAIN', 'index', '*', 'DIALECT', '1']
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,26 +1,28 @@
|
||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { Params, pushParamsArgs } from ".";
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
interface ExplainOptions {
|
||||
PARAMS?: Params;
|
||||
DIALECT?: number;
|
||||
export interface FtExplainOptions {
|
||||
PARAMS?: Params;
|
||||
DIALECT?: number;
|
||||
}
|
||||
|
||||
export function transformArguments(
|
||||
index: string,
|
||||
query: string,
|
||||
options?: ExplainOptions
|
||||
): Array<string> {
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(
|
||||
index: RedisArgument,
|
||||
query: RedisArgument,
|
||||
options?: FtExplainOptions
|
||||
) {
|
||||
const args = ['FT.EXPLAIN', index, query];
|
||||
|
||||
pushParamsArgs(args, options?.PARAMS);
|
||||
|
||||
if (options?.DIALECT) {
|
||||
args.push('DIALECT', options.DIALECT.toString());
|
||||
args.push('DIALECT', options.DIALECT.toString());
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { transformArguments } from './EXPLAINCLI';
|
||||
import EXPLAINCLI from './EXPLAINCLI';
|
||||
|
||||
describe('EXPLAINCLI', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('index', '*'),
|
||||
['FT.EXPLAINCLI', 'index', '*']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
EXPLAINCLI.transformArguments('index', '*'),
|
||||
['FT.EXPLAINCLI', 'index', '*']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@@ -1,7 +1,10 @@
|
||||
export const IS_READ_ONLY = true;
|
||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
|
||||
export function transformArguments(index: string, query: string): Array<string> {
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(index: RedisArgument, query: RedisArgument) {
|
||||
return ['FT.EXPLAINCLI', index, query];
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string>;
|
||||
},
|
||||
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,35 +1,35 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './SUGADD';
|
||||
import SUGADD from './SUGADD';
|
||||
|
||||
describe('SUGADD', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('without options', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'string', 1),
|
||||
['FT.SUGADD', 'key', 'string', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('with INCR', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'string', 1, { INCR: true }),
|
||||
['FT.SUGADD', 'key', 'string', '1', 'INCR']
|
||||
);
|
||||
});
|
||||
|
||||
it('with PAYLOAD', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'string', 1, { PAYLOAD: 'payload' }),
|
||||
['FT.SUGADD', 'key', 'string', '1', 'PAYLOAD', 'payload']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('without options', () => {
|
||||
assert.deepEqual(
|
||||
SUGADD.transformArguments('key', 'string', 1),
|
||||
['FT.SUGADD', 'key', 'string', '1']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.ft.sugAdd', async client => {
|
||||
assert.equal(
|
||||
await client.ft.sugAdd('key', 'string', 1),
|
||||
1
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
it('with INCR', () => {
|
||||
assert.deepEqual(
|
||||
SUGADD.transformArguments('key', 'string', 1, { INCR: true }),
|
||||
['FT.SUGADD', 'key', 'string', '1', 'INCR']
|
||||
);
|
||||
});
|
||||
|
||||
it('with PAYLOAD', () => {
|
||||
assert.deepEqual(
|
||||
SUGADD.transformArguments('key', 'string', 1, { PAYLOAD: 'payload' }),
|
||||
['FT.SUGADD', 'key', 'string', '1', 'PAYLOAD', 'payload']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.ft.sugAdd', async client => {
|
||||
assert.equal(
|
||||
await client.ft.sugAdd('key', 'string', 1),
|
||||
1
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,20 +1,25 @@
|
||||
interface SugAddOptions {
|
||||
INCR?: true;
|
||||
PAYLOAD?: string;
|
||||
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
|
||||
export interface FtSugAddOptions {
|
||||
INCR?: boolean;
|
||||
PAYLOAD?: RedisArgument;
|
||||
}
|
||||
|
||||
export function transformArguments(key: string, string: string, score: number, options?: SugAddOptions): Array<string> {
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, string: RedisArgument, score: number, options?: FtSugAddOptions) {
|
||||
const args = ['FT.SUGADD', key, string, score.toString()];
|
||||
|
||||
if (options?.INCR) {
|
||||
args.push('INCR');
|
||||
args.push('INCR');
|
||||
}
|
||||
|
||||
if (options?.PAYLOAD) {
|
||||
args.push('PAYLOAD', options.PAYLOAD);
|
||||
args.push('PAYLOAD', options.PAYLOAD);
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export declare function transformReply(): number;
|
||||
},
|
||||
transformReply: undefined as unknown as () => NumberReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,19 +1,19 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './SUGDEL';
|
||||
import SUGDEL from './SUGDEL';
|
||||
|
||||
describe('SUGDEL', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'string'),
|
||||
['FT.SUGDEL', 'key', 'string']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
SUGDEL.transformArguments('key', 'string'),
|
||||
['FT.SUGDEL', 'key', 'string']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.ft.sugDel', async client => {
|
||||
assert.equal(
|
||||
await client.ft.sugDel('key', 'string'),
|
||||
false
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testWithClient('client.ft.sugDel', async client => {
|
||||
assert.equal(
|
||||
await client.ft.sugDel('key', 'string'),
|
||||
false
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,5 +1,10 @@
|
||||
export function transformArguments(key: string, string: string): Array<string> {
|
||||
return ['FT.SUGDEL', key, string];
|
||||
}
|
||||
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
|
||||
export { transformBooleanReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, string: RedisArgument) {
|
||||
return ['FT.SUGDEL', key, string];
|
||||
},
|
||||
transformReply: undefined as unknown as () => NumberReply<0 | 1>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,19 +1,19 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './SUGLEN';
|
||||
import SUGLEN from './SUGLEN';
|
||||
|
||||
describe('SUGLEN', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key'),
|
||||
['FT.SUGLEN', 'key']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
SUGLEN.transformArguments('key'),
|
||||
['FT.SUGLEN', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.ft.sugLen', async client => {
|
||||
assert.equal(
|
||||
await client.ft.sugLen('key'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testWithClient('client.ft.sugLen', async client => {
|
||||
assert.equal(
|
||||
await client.ft.sugLen('key'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,7 +1,10 @@
|
||||
export const IS_READ_ONLY = true;
|
||||
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['FT.SUGLEN', key];
|
||||
}
|
||||
|
||||
export declare function transformReply(): number;
|
||||
},
|
||||
transformReply: undefined as unknown as () => NumberReply
|
||||
} as const satisfies Command;
|
||||
|
Reference in New Issue
Block a user