Skip to content

Commit ec7e82a

Browse files
committed
Preemptive modifications from previous reviews
1 parent b3be5fc commit ec7e82a

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

doctests/query-geo.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
// EXAMPLE: query_geo
22
// HIDE_START
3-
import assert from 'assert';
4-
import fs from 'fs';
3+
import assert from 'node:assert';
4+
import fs from 'node:fs';
55
import { createClient } from 'redis';
66
import { SchemaFieldTypes } from '@redis/search';
77

88
const client = createClient();
99

10-
await client.connect();
10+
await client.connect().catch(console.error);
1111

1212
// create index
1313
await client.ft.create('idx:bicycle', {
1414
'$.store_location': {
1515
type: SchemaFieldTypes.GEO,
1616
AS: 'store_location'
1717
},
18-
'$.pickup_zone': {
18+
'$.pickup_zone': {
1919
type: SchemaFieldTypes.GEOSHAPE,
2020
AS: 'pickup_zone'
2121
}
2222
}, {
23-
ON: 'JSON',
23+
ON: 'JSON',
2424
PREFIX: 'bicycle:'
2525
})
2626

@@ -35,31 +35,31 @@ await Promise.all(
3535
// HIDE_END
3636

3737
// STEP_START geo1
38-
let res = await client.ft.search('idx:bicycle', '@store_location:[-0.1778 51.5524 20 mi]');
39-
console.log(res.total); // >>> 1
40-
console.log(res); // >>> {total: 1, documents: [ { id: 'bicycle:5', value: [Object: null prototype] } ]}
38+
const res1= await client.ft.search('idx:bicycle', '@store_location:[-0.1778 51.5524 20 mi]');
39+
console.log(res1.total); // >>> 1
40+
console.log(res1); // >>> {total: 1, documents: [ { id: 'bicycle:5', value: [Object: null prototype] } ]}
4141
// REMOVE_START
42-
assert.strictEqual(res.total, 1);
42+
assert.strictEqual(res1.total, 1);
4343
// REMOVE_END
4444
// STEP_END
4545

4646
// STEP_START geo2
4747
const params_dict_geo2 = { bike: 'POINT(-0.1278 51.5074)' };
4848
const q_geo2 = '@pickup_zone:[CONTAINS $bike]';
49-
res = await client.ft.search('idx:bicycle', q_geo2, { PARAMS: params_dict_geo2, DIALECT: 3 });
50-
console.log(res.total); // >>> 1
51-
console.log(res); // >>> {total: 1, documents: [ { id: 'bicycle:5', value: [Object: null prototype] } ]}
49+
const res2 = await client.ft.search('idx:bicycle', q_geo2, { PARAMS: params_dict_geo2, DIALECT: 3 });
50+
console.log(res2.total); // >>> 1
51+
console.log(res2); // >>> {total: 1, documents: [ { id: 'bicycle:5', value: [Object: null prototype] } ]}
5252
// REMOVE_START
53-
assert.strictEqual(res.total, 1);
53+
assert.strictEqual(res2.total, 1);
5454
// REMOVE_END
5555
// STEP_END
5656

5757
// STEP_START geo3
5858
const params_dict_geo3 = { europe: 'POLYGON((-25 35, 40 35, 40 70, -25 70, -25 35))' };
5959
const q_geo3 = '@pickup_zone:[WITHIN $europe]';
60-
res = await client.ft.search('idx:bicycle', q_geo3, { PARAMS: params_dict_geo3, DIALECT: 3 });
61-
console.log(res.total); // >>> 5
62-
console.log(res); // >>>
60+
const res3 = await client.ft.search('idx:bicycle', q_geo3, { PARAMS: params_dict_geo3, DIALECT: 3 });
61+
console.log(res3.total); // >>> 5
62+
console.log(res3); // >>>
6363
// {
6464
// total: 5,
6565
// documents: [
@@ -71,7 +71,7 @@ console.log(res); // >>>
7171
// ]
7272
// }
7373
// REMOVE_START
74-
assert.strictEqual(res.total, 5);
74+
assert.strictEqual(res3.total, 5);
7575
// REMOVE_END
7676
// STEP_END
7777

0 commit comments

Comments
 (0)