Skip to content

Commit f6b56a1

Browse files
authored
feat(NODE-3651): add hashed index type (#3432)
1 parent fc719da commit f6b56a1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/operations/indexes.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,16 @@ const VALID_INDEX_OPTIONS = new Set([
5050
]);
5151

5252
/** @public */
53-
export type IndexDirection = -1 | 1 | '2d' | '2dsphere' | 'text' | 'geoHaystack' | number;
53+
export type IndexDirection =
54+
| -1
55+
| 1
56+
| '2d'
57+
| '2dsphere'
58+
| 'text'
59+
| 'geoHaystack'
60+
| 'hashed'
61+
| number;
62+
5463
function isIndexDirection(x: unknown): x is IndexDirection {
5564
return (
5665
typeof x === 'number' || x === '2d' || x === '2dsphere' || x === 'text' || x === 'geoHaystack'

test/types/community/createIndex.test-d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ collection.createIndex(['someKey', 1]);
1818
collection.createIndex(new Map([['someKey', 1]]));
1919
collection.createIndex({ a: 1, b: -1 });
2020
collection.createIndex({ a: '2dsphere', b: -1 });
21+
collection.createIndex({ a: 'hashed' });
2122
// OrMore
2223
collection.createIndex(['someKey']);
2324
collection.createIndex([['someKey', 1]]);
@@ -28,6 +29,7 @@ collection.createIndex([
2829
{ a: 'geoHaystack', b: 1 }
2930
]);
3031
collection.createIndex(['a', ['b', 1], { a: 'geoHaystack', b: 1 }, new Map([['someKey', 1]])]);
32+
collection.createIndex([{ a: 'hashed' }]);
3133

3234
// @ts-expect-error: CreateIndexes now asserts the object value types as of NODE-3517
3335
collection.createIndexes([{ key: { a: 34n } }]);

0 commit comments

Comments
 (0)