-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(NODE-4189): Support clustered collections #3229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
29b4478
a0cfedf
85bc6d9
a82720b
685b985
0d6a3ed
5f429cf
f92870e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,17 @@ export interface TimeSeriesCollectionOptions extends Document { | |
granularity?: 'seconds' | 'minutes' | 'hours' | string; | ||
} | ||
|
||
/** @public | ||
* Configuration options for clustered collections | ||
* TODO: NODE-4230 replace with normal manual link once it is on there. | ||
* @see https://www.mongodb.com/docs/v5.3/core/clustered-collections/ | ||
*/ | ||
export interface ClusteredCollectionOptions extends Document { | ||
name?: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name is optional and if left out the index will be named by the server automatically. |
||
key: Document; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the scope, key is required. But right now the only valid valid is |
||
unique: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the scope, unique is required. But right now it has to be set to |
||
} | ||
|
||
/** @public */ | ||
export interface CreateCollectionOptions extends CommandOperationOptions { | ||
/** Returns an error if the collection does not exist */ | ||
|
@@ -73,7 +84,9 @@ export interface CreateCollectionOptions extends CommandOperationOptions { | |
pkFactory?: PkFactory; | ||
/** A document specifying configuration options for timeseries collections. */ | ||
timeseries?: TimeSeriesCollectionOptions; | ||
/** The number of seconds after which a document in a timeseries collection expires. */ | ||
/** A document specifying configuration options for clustered collections. For MongoDB 5.3 and above. */ | ||
clusteredIndex?: ClusteredCollectionOptions; | ||
lerouxb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** The number of seconds after which a document in a timeseries or clustered collection expires. */ | ||
expireAfterSeconds?: number; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
{ | ||
"description": "clustered-indexes", | ||
"schemaVersion": "1.0", | ||
"runOnRequirements": [ | ||
{ | ||
"minServerVersion": "5.3" | ||
} | ||
], | ||
"createEntities": [ | ||
{ | ||
"client": { | ||
"id": "client0" | ||
} | ||
}, | ||
{ | ||
"database": { | ||
"id": "database0", | ||
"client": "client0", | ||
"databaseName": "ts-tests" | ||
} | ||
}, | ||
{ | ||
"collection": { | ||
"id": "collection0", | ||
"database": "database0", | ||
"collectionName": "test" | ||
} | ||
} | ||
], | ||
"initialData": [ | ||
{ | ||
"collectionName": "test", | ||
"databaseName": "ts-tests", | ||
"documents": [] | ||
} | ||
], | ||
"tests": [ | ||
{ | ||
"description": "createCollection with clusteredIndex", | ||
"operations": [ | ||
{ | ||
"name": "dropCollection", | ||
"object": "database0", | ||
"arguments": { | ||
"collection": "test" | ||
} | ||
}, | ||
{ | ||
"name": "createCollection", | ||
"object": "database0", | ||
"arguments": { | ||
"collection": "test", | ||
"clusteredIndex": { | ||
"key": { | ||
"_id": 1 | ||
}, | ||
"unique": true, | ||
"name": "test index" | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "assertCollectionExists", | ||
"object": "testRunner", | ||
"arguments": { | ||
"databaseName": "ts-tests", | ||
"collectionName": "test" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "listCollections includes clusteredIndex", | ||
"operations": [ | ||
{ | ||
"name": "dropCollection", | ||
"object": "database0", | ||
"arguments": { | ||
"collection": "test" | ||
} | ||
}, | ||
{ | ||
"name": "createCollection", | ||
"object": "database0", | ||
"arguments": { | ||
"collection": "test", | ||
"clusteredIndex": { | ||
"key": { | ||
"_id": 1 | ||
}, | ||
"unique": true, | ||
"name": "test index" | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "listCollections", | ||
"object": "database0", | ||
"arguments": { | ||
"filter": { | ||
"name": { | ||
"$eq": "test" | ||
} | ||
} | ||
}, | ||
"expectResult": [ | ||
{ | ||
"name": "test", | ||
"options": { | ||
"clusteredIndex": { | ||
"key": { | ||
"_id": 1 | ||
}, | ||
"unique": true, | ||
"name": "test index", | ||
"v": { | ||
"$$type": [ | ||
"int", | ||
"long" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "listIndexes returns the index", | ||
"operations": [ | ||
{ | ||
"name": "dropCollection", | ||
"object": "database0", | ||
"arguments": { | ||
"collection": "test" | ||
} | ||
}, | ||
{ | ||
"name": "createCollection", | ||
"object": "database0", | ||
"arguments": { | ||
"collection": "test", | ||
"clusteredIndex": { | ||
"key": { | ||
"_id": 1 | ||
}, | ||
"unique": true, | ||
"name": "test index" | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "listIndexes", | ||
"object": "collection0", | ||
"expectResult": [ | ||
{ | ||
"key": { | ||
"_id": 1 | ||
}, | ||
"name": "test index", | ||
"clustered": true, | ||
"unique": true, | ||
"v": { | ||
"$$type": [ | ||
"int", | ||
"long" | ||
] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
description: "clustered-indexes" | ||
|
||
schemaVersion: "1.0" | ||
|
||
runOnRequirements: | ||
- minServerVersion: "5.3" | ||
|
||
createEntities: | ||
- client: | ||
id: &client0 client0 | ||
- database: | ||
id: &database0 database0 | ||
client: *client0 | ||
databaseName: &database0Name ts-tests | ||
- collection: | ||
id: &collection0 collection0 | ||
database: *database0 | ||
collectionName: &collection0Name test | ||
|
||
initialData: | ||
- collectionName: *collection0Name | ||
databaseName: *database0Name | ||
documents: [] | ||
|
||
tests: | ||
- description: "createCollection with clusteredIndex" | ||
operations: | ||
- name: dropCollection | ||
object: *database0 | ||
arguments: | ||
collection: *collection0Name | ||
- name: createCollection | ||
object: *database0 | ||
arguments: | ||
collection: *collection0Name | ||
clusteredIndex: | ||
key: { _id: 1 } | ||
unique: true | ||
name: &index0Name "test index" | ||
- name: assertCollectionExists | ||
object: testRunner | ||
arguments: | ||
databaseName: *database0Name | ||
collectionName: *collection0Name | ||
|
||
- description: "listCollections includes clusteredIndex" | ||
operations: | ||
- name: dropCollection | ||
object: *database0 | ||
arguments: | ||
collection: *collection0Name | ||
- name: createCollection | ||
object: *database0 | ||
arguments: | ||
collection: *collection0Name | ||
clusteredIndex: | ||
key: { _id: 1 } | ||
unique: true | ||
name: &index0Name "test index" | ||
- name: listCollections | ||
object: *database0 | ||
arguments: | ||
filter: { name: { $eq: *collection0Name } } | ||
expectResult: | ||
- name: *collection0Name | ||
options: | ||
clusteredIndex: | ||
key: { _id: 1 } | ||
unique: true | ||
name: *index0Name | ||
v: { $$type: [ int, long ] } | ||
|
||
- description: "listIndexes returns the index" | ||
operations: | ||
- name: dropCollection | ||
object: *database0 | ||
arguments: | ||
collection: *collection0Name | ||
- name: createCollection | ||
object: *database0 | ||
arguments: | ||
collection: *collection0Name | ||
clusteredIndex: | ||
key: { _id: 1 } | ||
unique: true | ||
name: *index0Name | ||
- name: listIndexes | ||
object: *collection0 | ||
expectResult: | ||
- key: { _id: 1 } | ||
name: *index0Name | ||
clustered: true | ||
unique: true | ||
v: { $$type: [ int, long ] } |
Uh oh!
There was an error while loading. Please reload this page.