Skip to content

Commit 8655aa1

Browse files
committed
fix(doctests): update deprecated methods and imports for v5 compliance
- Fix dt-string.js: remove await from client creation and replace client.quit() with client.close() - Fix dt-tdigest.js: replace deprecated client.quit() with client.close() - Fix dt-topk.js: replace client.quit() with client.close() and fix output comment from [1, 0] to [true, false] - Fix query-agg.js: update @redis/search imports to use new constant names and replace client.disconnect() with client.close()
1 parent be450c1 commit 8655aa1

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

doctests/dt-string.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import assert from 'assert';
44
import { createClient } from 'redis';
55

6-
const client = await createClient();
6+
const client = createClient();
77
await client.connect();
88
// HIDE_END
99
// REMOVE_START
@@ -64,5 +64,5 @@ console.log(res8); // 11
6464
assert.equal(res7, 1);
6565
assert.equal(res8, 11);
6666

67-
await client.quit();
67+
await client.close();
6868
// REMOVE_END

doctests/dt-tdigest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ console.log(res12); // >>> OK
8181

8282
// REMOVE_START
8383
assert.equal(res12, 'OK')
84-
await client.quit();
84+
await client.close();
8585
// REMOVE_END

doctests/dt-topk.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ const res3 = await client.topK.list('bikes:keywords');
3535
console.log(res3); // >>> ['store', 'seat', 'pedals', 'tires', 'handles']
3636

3737
const res4 = await client.topK.query('bikes:keywords', ['store', 'handlebars']);
38-
console.log(res4); // >>> [1, 0]
38+
console.log(res4); // >>> [true, false]
3939
// STEP_END
4040

4141
// REMOVE_START
4242
assert.equal(res1, 'OK')
4343
assert.deepEqual(res2, [null, null, null, null, null, 'handlebars', null, null])
4444
assert.deepEqual(res3, ['store', 'seat', 'pedals', 'tires', 'handles'])
4545
assert.deepEqual(res4, [1, 0])
46-
await client.quit();
46+
await client.close();
4747
// REMOVE_END
4848

doctests/query-agg.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import assert from 'node:assert';
44
import fs from 'node:fs';
55
import { createClient } from 'redis';
6-
import { SchemaFieldTypes, AggregateSteps, AggregateGroupByReducers } from '@redis/search';
6+
import { SCHEMA_FIELD_TYPE, FT_AGGREGATE_STEPS, FT_AGGREGATE_GROUP_BY_REDUCERS } from '@redis/search';
77

88
const client = createClient();
99

@@ -12,11 +12,11 @@ await client.connect().catch(console.error);
1212
// create index
1313
await client.ft.create('idx:bicycle', {
1414
'$.condition': {
15-
type: SchemaFieldTypes.TAG,
15+
type: SCHEMA_FIELD_TYPE.TAG,
1616
AS: 'condition'
1717
},
1818
'$.price': {
19-
type: SchemaFieldTypes.NUMERIC,
19+
type: SCHEMA_FIELD_TYPE.NUMERIC,
2020
AS: 'price'
2121
}
2222
}, {
@@ -61,14 +61,14 @@ assert.strictEqual(res1.results.length, 5);
6161
const res2 = await client.ft.aggregate('idx:bicycle', '*', {
6262
LOAD: ['@price'],
6363
STEPS: [{
64-
type: AggregateSteps.APPLY,
64+
type: FT_AGGREGATE_STEPS.APPLY,
6565
expression: '@price<1000',
6666
AS: 'price_category'
6767
},{
68-
type: AggregateSteps.GROUPBY,
68+
type: FT_AGGREGATE_STEPS.GROUPBY,
6969
properties: '@condition',
7070
REDUCE:[{
71-
type: AggregateGroupByReducers.SUM,
71+
type: FT_AGGREGATE_GROUP_BY_REDUCERS.SUM,
7272
property: '@price_category',
7373
AS: 'num_affordable'
7474
}]
@@ -88,14 +88,14 @@ assert.strictEqual(res2.results.length, 3);
8888
// STEP_START agg3
8989
const res3 = await client.ft.aggregate('idx:bicycle', '*', {
9090
STEPS: [{
91-
type: AggregateSteps.APPLY,
91+
type: FT_AGGREGATE_STEPS.APPLY,
9292
expression: "'bicycle'",
9393
AS: 'type'
9494
}, {
95-
type: AggregateSteps.GROUPBY,
95+
type: FT_AGGREGATE_STEPS.GROUPBY,
9696
properties: '@type',
9797
REDUCE: [{
98-
type: AggregateGroupByReducers.COUNT,
98+
type: FT_AGGREGATE_GROUP_BY_REDUCERS.COUNT,
9999
property: null,
100100
AS: 'num_total'
101101
}]
@@ -113,10 +113,10 @@ assert.strictEqual(res3.results.length, 1);
113113
const res4 = await client.ft.aggregate('idx:bicycle', '*', {
114114
LOAD: ['__key'],
115115
STEPS: [{
116-
type: AggregateSteps.GROUPBY,
116+
type: FT_AGGREGATE_STEPS.GROUPBY,
117117
properties: '@condition',
118118
REDUCE: [{
119-
type: AggregateGroupByReducers.TOLIST,
119+
type: FT_AGGREGATE_GROUP_BY_REDUCERS.TOLIST,
120120
property: '__key',
121121
AS: 'bicycles'
122122
}]
@@ -135,5 +135,5 @@ assert.strictEqual(res4.results.length, 3);
135135
// REMOVE_START
136136
// destroy index and data
137137
await client.ft.dropIndex('idx:bicycle', { DD: true });
138-
await client.disconnect();
138+
await client.close();
139139
// REMOVE_END

0 commit comments

Comments
 (0)