mongodb 6.19.0-dev.20250903.sha.98c5d830 → 6.19.0-dev.20250909.sha.43c85189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/beta.d.ts +16 -9
- package/lib/change_stream.js +5 -1
- package/lib/change_stream.js.map +1 -1
- package/lib/cmap/wire_protocol/constants.js +5 -3
- package/lib/cmap/wire_protocol/constants.js.map +1 -1
- package/lib/operations/aggregate.js +2 -1
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/client_bulk_write/client_bulk_write.js +2 -1
- package/lib/operations/client_bulk_write/client_bulk_write.js.map +1 -1
- package/lib/operations/command.js +6 -0
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/count.js +1 -1
- package/lib/operations/count.js.map +1 -1
- package/lib/operations/delete.js +13 -7
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/distinct.js +6 -1
- package/lib/operations/distinct.js.map +1 -1
- package/lib/operations/estimated_document_count.js +2 -1
- package/lib/operations/estimated_document_count.js.map +1 -1
- package/lib/operations/find.js +2 -1
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/find_and_modify.js +5 -4
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/indexes.js +4 -3
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js +10 -2
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/list_collections.js +2 -1
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/operations/operation.js +2 -1
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/update.js +12 -11
- package/lib/operations/update.js.map +1 -1
- package/lib/utils.js +22 -17
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +16 -9
- package/package.json +1 -1
- package/src/change_stream.ts +5 -1
- package/src/cmap/wire_protocol/constants.ts +4 -2
- package/src/operations/aggregate.ts +2 -1
- package/src/operations/client_bulk_write/client_bulk_write.ts +2 -1
- package/src/operations/command.ts +18 -1
- package/src/operations/count.ts +1 -1
- package/src/operations/create_collection.ts +1 -1
- package/src/operations/delete.ts +15 -8
- package/src/operations/distinct.ts +6 -1
- package/src/operations/drop.ts +1 -1
- package/src/operations/estimated_document_count.ts +2 -1
- package/src/operations/find.ts +2 -1
- package/src/operations/find_and_modify.ts +6 -5
- package/src/operations/indexes.ts +5 -4
- package/src/operations/insert.ts +10 -2
- package/src/operations/list_collections.ts +2 -1
- package/src/operations/list_databases.ts +1 -1
- package/src/operations/operation.ts +2 -1
- package/src/operations/profiling_level.ts +1 -1
- package/src/operations/remove_user.ts +1 -1
- package/src/operations/rename.ts +1 -1
- package/src/operations/set_profiling_level.ts +1 -1
- package/src/operations/stats.ts +1 -1
- package/src/operations/update.ts +13 -13
- package/src/operations/validate_collection.ts +1 -1
- package/src/utils.ts +23 -17
|
@@ -6,7 +6,7 @@ import { MongoCompatibilityError, MongoInvalidArgumentError } from '../error';
|
|
|
6
6
|
import { ReadPreference } from '../read_preference';
|
|
7
7
|
import type { ClientSession } from '../sessions';
|
|
8
8
|
import { formatSort, type Sort, type SortForCmd } from '../sort';
|
|
9
|
-
import { decorateWithCollation, hasAtomicOperators } from '../utils';
|
|
9
|
+
import { decorateWithCollation, hasAtomicOperators, maxWireVersion } from '../utils';
|
|
10
10
|
import { type WriteConcern, type WriteConcernSettings } from '../write_concern';
|
|
11
11
|
import { CommandOperation, type CommandOperationOptions } from './command';
|
|
12
12
|
import { Aspect, defineAspects } from './operation';
|
|
@@ -146,7 +146,7 @@ export class FindAndModifyOperation extends CommandOperation<Document> {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
override buildCommandDocument(
|
|
149
|
-
|
|
149
|
+
connection: Connection,
|
|
150
150
|
_session?: ClientSession
|
|
151
151
|
): Document & FindAndModifyCmdBase {
|
|
152
152
|
const options = this.options;
|
|
@@ -192,9 +192,9 @@ export class FindAndModifyOperation extends CommandOperation<Document> {
|
|
|
192
192
|
|
|
193
193
|
if (options.hint) {
|
|
194
194
|
const unacknowledgedWrite = this.writeConcern?.w === 0;
|
|
195
|
-
if (unacknowledgedWrite) {
|
|
195
|
+
if (unacknowledgedWrite && maxWireVersion(connection) < 9) {
|
|
196
196
|
throw new MongoCompatibilityError(
|
|
197
|
-
'
|
|
197
|
+
'hint for the findAndModify command is only supported on MongoDB 4.4+'
|
|
198
198
|
);
|
|
199
199
|
}
|
|
200
200
|
|
|
@@ -314,5 +314,6 @@ export class FindOneAndUpdateOperation extends FindAndModifyOperation {
|
|
|
314
314
|
defineAspects(FindAndModifyOperation, [
|
|
315
315
|
Aspect.WRITE_OPERATION,
|
|
316
316
|
Aspect.RETRYABLE,
|
|
317
|
-
Aspect.EXPLAINABLE
|
|
317
|
+
Aspect.EXPLAINABLE,
|
|
318
|
+
Aspect.SUPPORTS_RAW_DATA
|
|
318
319
|
]);
|
|
@@ -368,7 +368,7 @@ export class ListIndexesOperation extends CommandOperation<CursorResponse> {
|
|
|
368
368
|
* This allows typescript to delete the key but will
|
|
369
369
|
* not allow a writeConcern to be assigned as a property on options.
|
|
370
370
|
*/
|
|
371
|
-
override options: ListIndexesOptions & { writeConcern?: never };
|
|
371
|
+
override options: ListIndexesOptions & { writeConcern?: never; rawData?: boolean };
|
|
372
372
|
collectionNamespace: MongoDBNamespace;
|
|
373
373
|
|
|
374
374
|
constructor(collection: Collection, options?: ListIndexesOptions) {
|
|
@@ -409,7 +409,8 @@ export class ListIndexesOperation extends CommandOperation<CursorResponse> {
|
|
|
409
409
|
defineAspects(ListIndexesOperation, [
|
|
410
410
|
Aspect.READ_OPERATION,
|
|
411
411
|
Aspect.RETRYABLE,
|
|
412
|
-
Aspect.CURSOR_CREATING
|
|
412
|
+
Aspect.CURSOR_CREATING,
|
|
413
|
+
Aspect.SUPPORTS_RAW_DATA
|
|
413
414
|
]);
|
|
414
|
-
defineAspects(CreateIndexesOperation, [Aspect.WRITE_OPERATION]);
|
|
415
|
-
defineAspects(DropIndexOperation, [Aspect.WRITE_OPERATION]);
|
|
415
|
+
defineAspects(CreateIndexesOperation, [Aspect.WRITE_OPERATION, Aspect.SUPPORTS_RAW_DATA]);
|
|
416
|
+
defineAspects(DropIndexOperation, [Aspect.WRITE_OPERATION, Aspect.SUPPORTS_RAW_DATA]);
|
package/src/operations/insert.ts
CHANGED
|
@@ -96,5 +96,13 @@ export interface InsertManyResult<TSchema = Document> {
|
|
|
96
96
|
insertedIds: { [key: number]: InferIdType<TSchema> };
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
defineAspects(InsertOperation, [
|
|
100
|
-
|
|
99
|
+
defineAspects(InsertOperation, [
|
|
100
|
+
Aspect.RETRYABLE,
|
|
101
|
+
Aspect.WRITE_OPERATION,
|
|
102
|
+
Aspect.SUPPORTS_RAW_DATA
|
|
103
|
+
]);
|
|
104
|
+
defineAspects(InsertOneOperation, [
|
|
105
|
+
Aspect.RETRYABLE,
|
|
106
|
+
Aspect.WRITE_OPERATION,
|
|
107
|
+
Aspect.SUPPORTS_RAW_DATA
|
|
108
|
+
]);
|
|
@@ -16,7 +16,7 @@ export interface ListDatabasesResult {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/** @public */
|
|
19
|
-
export interface ListDatabasesOptions extends CommandOperationOptions {
|
|
19
|
+
export interface ListDatabasesOptions extends Omit<CommandOperationOptions, 'rawData'> {
|
|
20
20
|
/** A query predicate that determines which databases are listed */
|
|
21
21
|
filter?: Document;
|
|
22
22
|
/** A flag to indicate whether the command should return just the database names, or return both database names and size information */
|
|
@@ -16,7 +16,8 @@ export const Aspect = {
|
|
|
16
16
|
SKIP_COLLATION: Symbol('SKIP_COLLATION'),
|
|
17
17
|
CURSOR_CREATING: Symbol('CURSOR_CREATING'),
|
|
18
18
|
MUST_SELECT_SAME_SERVER: Symbol('MUST_SELECT_SAME_SERVER'),
|
|
19
|
-
COMMAND_BATCHING: Symbol('COMMAND_BATCHING')
|
|
19
|
+
COMMAND_BATCHING: Symbol('COMMAND_BATCHING'),
|
|
20
|
+
SUPPORTS_RAW_DATA: Symbol('SUPPORTS_RAW_DATA')
|
|
20
21
|
} as const;
|
|
21
22
|
|
|
22
23
|
/** @public */
|
|
@@ -6,7 +6,7 @@ import { MongoUnexpectedServerResponseError } from '../error';
|
|
|
6
6
|
import { CommandOperation, type CommandOperationOptions } from './command';
|
|
7
7
|
|
|
8
8
|
/** @public */
|
|
9
|
-
export type ProfilingLevelOptions = CommandOperationOptions
|
|
9
|
+
export type ProfilingLevelOptions = Omit<CommandOperationOptions, 'rawData'>;
|
|
10
10
|
|
|
11
11
|
class ProfilingLevelResponse extends MongoDBResponse {
|
|
12
12
|
get was() {
|
|
@@ -6,7 +6,7 @@ import { CommandOperation, type CommandOperationOptions } from './command';
|
|
|
6
6
|
import { Aspect, defineAspects } from './operation';
|
|
7
7
|
|
|
8
8
|
/** @public */
|
|
9
|
-
export type RemoveUserOptions = CommandOperationOptions
|
|
9
|
+
export type RemoveUserOptions = Omit<CommandOperationOptions, 'rawData'>;
|
|
10
10
|
|
|
11
11
|
/** @internal */
|
|
12
12
|
export class RemoveUserOperation extends CommandOperation<boolean> {
|
package/src/operations/rename.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { CommandOperation, type CommandOperationOptions } from './command';
|
|
|
8
8
|
import { Aspect, defineAspects } from './operation';
|
|
9
9
|
|
|
10
10
|
/** @public */
|
|
11
|
-
export interface RenameOptions extends CommandOperationOptions {
|
|
11
|
+
export interface RenameOptions extends Omit<CommandOperationOptions, 'rawData'> {
|
|
12
12
|
/** Drop the target name collection if it previously exists. */
|
|
13
13
|
dropTarget?: boolean;
|
|
14
14
|
/** Unclear */
|
|
@@ -19,7 +19,7 @@ export const ProfilingLevel = Object.freeze({
|
|
|
19
19
|
export type ProfilingLevel = (typeof ProfilingLevel)[keyof typeof ProfilingLevel];
|
|
20
20
|
|
|
21
21
|
/** @public */
|
|
22
|
-
export type SetProfilingLevelOptions = CommandOperationOptions
|
|
22
|
+
export type SetProfilingLevelOptions = Omit<CommandOperationOptions, 'rawData'>;
|
|
23
23
|
|
|
24
24
|
/** @internal */
|
|
25
25
|
export class SetProfilingLevelOperation extends CommandOperation<ProfilingLevel> {
|
package/src/operations/stats.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { CommandOperation, type CommandOperationOptions } from './command';
|
|
|
6
6
|
import { Aspect, defineAspects } from './operation';
|
|
7
7
|
|
|
8
8
|
/** @public */
|
|
9
|
-
export interface DbStatsOptions extends CommandOperationOptions {
|
|
9
|
+
export interface DbStatsOptions extends Omit<CommandOperationOptions, 'rawData'> {
|
|
10
10
|
/** Divide the returned sizes by scale value. */
|
|
11
11
|
scale?: number;
|
|
12
12
|
}
|
package/src/operations/update.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Document } from '../bson';
|
|
2
2
|
import { type Connection } from '../cmap/connection';
|
|
3
3
|
import { MongoDBResponse } from '../cmap/wire_protocol/responses';
|
|
4
|
-
import {
|
|
4
|
+
import { MongoInvalidArgumentError, MongoServerError } from '../error';
|
|
5
5
|
import type { InferIdType } from '../mongo_types';
|
|
6
6
|
import type { ClientSession } from '../sessions';
|
|
7
7
|
import { formatSort, type Sort, type SortForCmd } from '../sort';
|
|
@@ -121,14 +121,6 @@ export class UpdateOperation extends CommandOperation<Document> {
|
|
|
121
121
|
command.comment = options.comment;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
const unacknowledgedWrite = this.writeConcern?.w === 0;
|
|
125
|
-
if (unacknowledgedWrite) {
|
|
126
|
-
if (this.statements.find((o: Document) => o.hint)) {
|
|
127
|
-
// TODO(NODE-3541): fix error for hint with unacknowledged writes
|
|
128
|
-
throw new MongoCompatibilityError(`hint is not supported with unacknowledged writes`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
124
|
return command;
|
|
133
125
|
}
|
|
134
126
|
}
|
|
@@ -299,20 +291,28 @@ export function makeUpdateStatement(
|
|
|
299
291
|
return op;
|
|
300
292
|
}
|
|
301
293
|
|
|
302
|
-
defineAspects(UpdateOperation, [
|
|
294
|
+
defineAspects(UpdateOperation, [
|
|
295
|
+
Aspect.RETRYABLE,
|
|
296
|
+
Aspect.WRITE_OPERATION,
|
|
297
|
+
Aspect.SKIP_COLLATION,
|
|
298
|
+
Aspect.SUPPORTS_RAW_DATA
|
|
299
|
+
]);
|
|
303
300
|
defineAspects(UpdateOneOperation, [
|
|
304
301
|
Aspect.RETRYABLE,
|
|
305
302
|
Aspect.WRITE_OPERATION,
|
|
306
303
|
Aspect.EXPLAINABLE,
|
|
307
|
-
Aspect.SKIP_COLLATION
|
|
304
|
+
Aspect.SKIP_COLLATION,
|
|
305
|
+
Aspect.SUPPORTS_RAW_DATA
|
|
308
306
|
]);
|
|
309
307
|
defineAspects(UpdateManyOperation, [
|
|
310
308
|
Aspect.WRITE_OPERATION,
|
|
311
309
|
Aspect.EXPLAINABLE,
|
|
312
|
-
Aspect.SKIP_COLLATION
|
|
310
|
+
Aspect.SKIP_COLLATION,
|
|
311
|
+
Aspect.SUPPORTS_RAW_DATA
|
|
313
312
|
]);
|
|
314
313
|
defineAspects(ReplaceOneOperation, [
|
|
315
314
|
Aspect.RETRYABLE,
|
|
316
315
|
Aspect.WRITE_OPERATION,
|
|
317
|
-
Aspect.SKIP_COLLATION
|
|
316
|
+
Aspect.SKIP_COLLATION,
|
|
317
|
+
Aspect.SUPPORTS_RAW_DATA
|
|
318
318
|
]);
|
|
@@ -7,7 +7,7 @@ import type { ClientSession } from '../sessions';
|
|
|
7
7
|
import { CommandOperation, type CommandOperationOptions } from './command';
|
|
8
8
|
|
|
9
9
|
/** @public */
|
|
10
|
-
export interface ValidateCollectionOptions extends CommandOperationOptions {
|
|
10
|
+
export interface ValidateCollectionOptions extends Omit<CommandOperationOptions, 'rawData'> {
|
|
11
11
|
/** Validates a collection in the background, without interrupting read or write traffic (only in MongoDB 4.4+) */
|
|
12
12
|
background?: boolean;
|
|
13
13
|
}
|
package/src/utils.ts
CHANGED
|
@@ -359,34 +359,40 @@ export function uuidV4(): Buffer {
|
|
|
359
359
|
* A helper function for determining `maxWireVersion` between legacy and new topology instances
|
|
360
360
|
* @internal
|
|
361
361
|
*/
|
|
362
|
-
export function maxWireVersion(
|
|
363
|
-
if (
|
|
364
|
-
if (
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
//
|
|
370
|
-
// We also return the max supported wire version for serverAPI.
|
|
362
|
+
export function maxWireVersion(handshakeAware?: Connection | Topology | Server): number {
|
|
363
|
+
if (handshakeAware) {
|
|
364
|
+
if (handshakeAware.hello) {
|
|
365
|
+
return handshakeAware.hello.maxWireVersion;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (handshakeAware.serverApi?.version) {
|
|
369
|
+
// We return the max supported wire version for serverAPI.
|
|
371
370
|
return MAX_SUPPORTED_WIRE_VERSION;
|
|
372
371
|
}
|
|
373
|
-
|
|
374
|
-
|
|
372
|
+
// This is the fallback case for load balanced mode. If we are building commands the
|
|
373
|
+
// object being checked will be a connection, and we will have a hello response on
|
|
374
|
+
// it. For other cases, such as retryable writes, the object will be a server or
|
|
375
|
+
// topology, and there will be no hello response on those objects, so we return
|
|
376
|
+
// the max wire version so we support retryability. Once we have a min supported
|
|
377
|
+
// wire version of 9, then the needsRetryableWriteLabel() check can remove the
|
|
378
|
+
// usage of passing the wire version into it.
|
|
379
|
+
if (handshakeAware.loadBalanced) {
|
|
380
|
+
return MAX_SUPPORTED_WIRE_VERSION;
|
|
375
381
|
}
|
|
376
382
|
|
|
377
|
-
if ('lastHello' in
|
|
378
|
-
const lastHello =
|
|
383
|
+
if ('lastHello' in handshakeAware && typeof handshakeAware.lastHello === 'function') {
|
|
384
|
+
const lastHello = handshakeAware.lastHello();
|
|
379
385
|
if (lastHello) {
|
|
380
386
|
return lastHello.maxWireVersion;
|
|
381
387
|
}
|
|
382
388
|
}
|
|
383
389
|
|
|
384
390
|
if (
|
|
385
|
-
|
|
386
|
-
'maxWireVersion' in
|
|
387
|
-
|
|
391
|
+
handshakeAware.description &&
|
|
392
|
+
'maxWireVersion' in handshakeAware.description &&
|
|
393
|
+
handshakeAware.description.maxWireVersion != null
|
|
388
394
|
) {
|
|
389
|
-
return
|
|
395
|
+
return handshakeAware.description.maxWireVersion;
|
|
390
396
|
}
|
|
391
397
|
}
|
|
392
398
|
|