Skip to content

Commit 0fa3cd4

Browse files
feat(NODE-6883): allow rawData option on time series collections (#4642)
Co-authored-by: Bailey Pearson <[email protected]>
1 parent 8331a93 commit 0fa3cd4

File tree

80 files changed

+5422
-53
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+5422
-53
lines changed

src/cmap/wire_protocol/constants.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
export const MIN_SUPPORTED_SERVER_VERSION = '4.2';
2-
export const MAX_SUPPORTED_SERVER_VERSION = '8.0';
2+
export const MAX_SUPPORTED_SERVER_VERSION = '8.2';
33
export const MIN_SUPPORTED_WIRE_VERSION = 8;
4-
export const MAX_SUPPORTED_WIRE_VERSION = 25;
4+
export const MAX_SUPPORTED_WIRE_VERSION = 27;
55
export const MIN_SUPPORTED_QE_WIRE_VERSION = 21;
66
export const MIN_SUPPORTED_QE_SERVER_VERSION = '7.0';
7+
export const MIN_SUPPORTED_RAW_DATA_WIRE_VERSION = 27;
8+
export const MIN_SUPPORTED_RAW_DATA_SERVER_VERSION = '8.2';
79
export const OP_REPLY = 1;
810
export const OP_UPDATE = 2001;
911
export const OP_INSERT = 2002;

src/operations/aggregate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,6 @@ defineAspects(AggregateOperation, [
161161
Aspect.READ_OPERATION,
162162
Aspect.RETRYABLE,
163163
Aspect.EXPLAINABLE,
164-
Aspect.CURSOR_CREATING
164+
Aspect.CURSOR_CREATING,
165+
Aspect.SUPPORTS_RAW_DATA
165166
]);

src/operations/client_bulk_write/client_bulk_write.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ defineAspects(ClientBulkWriteOperation, [
6767
Aspect.SKIP_COLLATION,
6868
Aspect.CURSOR_CREATING,
6969
Aspect.RETRYABLE,
70-
Aspect.COMMAND_BATCHING
70+
Aspect.COMMAND_BATCHING,
71+
Aspect.SUPPORTS_RAW_DATA
7172
]);

src/operations/command.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { type Connection } from '..';
22
import type { BSONSerializeOptions, Document } from '../bson';
3+
import { MIN_SUPPORTED_RAW_DATA_WIRE_VERSION } from '../cmap/wire_protocol/constants';
34
import { MongoInvalidArgumentError } from '../error';
45
import {
56
decorateWithExplain,
@@ -12,7 +13,7 @@ import type { ReadPreference } from '../read_preference';
1213
import type { ServerCommandOptions } from '../sdam/server';
1314
import type { ClientSession } from '../sessions';
1415
import { type TimeoutContext } from '../timeout';
15-
import { commandSupportsReadConcern, MongoDBNamespace } from '../utils';
16+
import { commandSupportsReadConcern, maxWireVersion, MongoDBNamespace } from '../utils';
1617
import { WriteConcern, type WriteConcernOptions } from '../write_concern';
1718
import type { ReadConcernLike } from './../read_concern';
1819
import { AbstractOperation, Aspect, type OperationOptions } from './operation';
@@ -63,6 +64,14 @@ export interface CommandOperationOptions
6364
* This option is deprecated and will be removed in an upcoming major version.
6465
*/
6566
noResponse?: boolean;
67+
68+
/**
69+
* Used when the command needs to grant access to the underlying namespaces for time series collections.
70+
* Only available on server versions 8.2 and above.
71+
* @public
72+
* @sinceServerVersion 8.2
73+
**/
74+
rawData?: boolean;
6675
}
6776

6877
/** @internal */
@@ -153,6 +162,14 @@ export abstract class CommandOperation<T> extends AbstractOperation<T> {
153162
command.maxTimeMS = this.options.maxTimeMS;
154163
}
155164

165+
if (
166+
this.options.rawData != null &&
167+
this.hasAspect(Aspect.SUPPORTS_RAW_DATA) &&
168+
maxWireVersion(connection) >= MIN_SUPPORTED_RAW_DATA_WIRE_VERSION
169+
) {
170+
command.rawData = this.options.rawData;
171+
}
172+
156173
if (this.hasAspect(Aspect.EXPLAINABLE) && this.explain) {
157174
return decorateWithExplain(command, this.explain);
158175
}

src/operations/count.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ export class CountOperation extends CommandOperation<number> {
7171
}
7272
}
7373

74-
defineAspects(CountOperation, [Aspect.READ_OPERATION, Aspect.RETRYABLE]);
74+
defineAspects(CountOperation, [Aspect.READ_OPERATION, Aspect.RETRYABLE, Aspect.SUPPORTS_RAW_DATA]);

src/operations/create_collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export interface ClusteredCollectionOptions extends Document {
6565
}
6666

6767
/** @public */
68-
export interface CreateCollectionOptions extends CommandOperationOptions {
68+
export interface CreateCollectionOptions extends Omit<CommandOperationOptions, 'rawData'> {
6969
/** Create a capped collection */
7070
capped?: boolean;
7171
/** @deprecated Create an index on the _id field of the document. This option is deprecated in MongoDB 3.2+ and will be removed once no longer supported by the server. */

src/operations/delete.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,21 @@ export function makeDeleteStatement(
163163
return op;
164164
}
165165

166-
defineAspects(DeleteOperation, [Aspect.RETRYABLE, Aspect.WRITE_OPERATION]);
166+
defineAspects(DeleteOperation, [
167+
Aspect.RETRYABLE,
168+
Aspect.WRITE_OPERATION,
169+
Aspect.SUPPORTS_RAW_DATA
170+
]);
167171
defineAspects(DeleteOneOperation, [
168172
Aspect.RETRYABLE,
169173
Aspect.WRITE_OPERATION,
170174
Aspect.EXPLAINABLE,
171-
Aspect.SKIP_COLLATION
175+
Aspect.SKIP_COLLATION,
176+
Aspect.SUPPORTS_RAW_DATA
172177
]);
173178
defineAspects(DeleteManyOperation, [
174179
Aspect.WRITE_OPERATION,
175180
Aspect.EXPLAINABLE,
176-
Aspect.SKIP_COLLATION
181+
Aspect.SKIP_COLLATION,
182+
Aspect.SUPPORTS_RAW_DATA
177183
]);

src/operations/distinct.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,9 @@ export class DistinctOperation extends CommandOperation<any[] | Document> {
8484
}
8585
}
8686

87-
defineAspects(DistinctOperation, [Aspect.READ_OPERATION, Aspect.RETRYABLE, Aspect.EXPLAINABLE]);
87+
defineAspects(DistinctOperation, [
88+
Aspect.READ_OPERATION,
89+
Aspect.RETRYABLE,
90+
Aspect.EXPLAINABLE,
91+
Aspect.SUPPORTS_RAW_DATA
92+
]);

src/operations/drop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { executeOperation } from './execute_operation';
1111
import { Aspect, defineAspects } from './operation';
1212

1313
/** @public */
14-
export interface DropCollectionOptions extends CommandOperationOptions {
14+
export interface DropCollectionOptions extends Omit<CommandOperationOptions, 'rawData'> {
1515
/** @experimental */
1616
encryptedFields?: Document;
1717
}

src/operations/estimated_document_count.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@ export class EstimatedDocumentCountOperation extends CommandOperation<number> {
5656
defineAspects(EstimatedDocumentCountOperation, [
5757
Aspect.READ_OPERATION,
5858
Aspect.RETRYABLE,
59-
Aspect.CURSOR_CREATING
59+
Aspect.CURSOR_CREATING,
60+
Aspect.SUPPORTS_RAW_DATA
6061
]);

0 commit comments

Comments
 (0)