Skip to content

Commit e1d691a

Browse files
authored
Merge branch 'main' into NODE-3818
2 parents 91c4f13 + 8900d40 commit e1d691a

File tree

5 files changed

+12
-215
lines changed

5 files changed

+12
-215
lines changed

etc/notes/CHANGES_5.0.0.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ The following is a detailed collection of the changes in the major v5 release of
2121
The deprecated `slaveOk` option and `slaveOk()` method on the `Collection` class have been removed. Please
2222
now use `secondaryOk` as the replacement for the option and the method.
2323

24+
### Bulk results no longer contain `lastOp()` and `opTime`
25+
26+
The `lastOp()` method and `opTime` property on the `BulkResult` have been removed. Merging of bulk results
27+
no longer normalizes the values. There is no new method or property to replace them.
28+
29+
### `CursorCloseOptions` removed
30+
31+
When calling `close()` on a `Cursor`, no more options can be provided. This removes support for the
32+
`skipKillCursors` option that was unused.
33+
2434
### Snappy v7.x.x or later and optional peerDependency
2535

2636
`snappy` compression has been added to the package.json as a peerDependency that is **optional**.

src/bulk/common.ts

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
BSONSerializeOptions,
3-
Document,
4-
Long,
5-
ObjectId,
6-
resolveBSONOptions,
7-
Timestamp
8-
} from '../bson';
1+
import { BSONSerializeOptions, Document, ObjectId, resolveBSONOptions } from '../bson';
92
import type { Collection } from '../collection';
103
import {
114
AnyError,
@@ -146,7 +139,6 @@ export interface BulkResult {
146139
nModified: number;
147140
nRemoved: number;
148141
upserted: Document[];
149-
opTime?: Document;
150142
}
151143

152144
/**
@@ -300,15 +292,6 @@ export class BulkWriteResult {
300292
return this.result.writeErrors;
301293
}
302294

303-
/**
304-
* Retrieve lastOp if available
305-
*
306-
* @deprecated Will be removed in 5.0
307-
*/
308-
getLastOp(): Document | undefined {
309-
return this.result.opTime;
310-
}
311-
312295
/** Retrieve the write concern error if one exists */
313296
getWriteConcernError(): WriteConcernError | undefined {
314297
if (this.result.writeConcernErrors.length === 0) {
@@ -449,12 +432,6 @@ export class WriteError {
449432
}
450433
}
451434

452-
/** Converts the number to a Long or returns it. */
453-
function longOrConvert(value: number | Long | Timestamp): Long | Timestamp {
454-
// TODO(NODE-2674): Preserve int64 sent from MongoDB
455-
return typeof value === 'number' ? Long.fromNumber(value) : value;
456-
}
457-
458435
/** Merges results into shared data structure */
459436
export function mergeBatchResults(
460437
batch: Batch,
@@ -491,44 +468,6 @@ export function mergeBatchResults(
491468
return;
492469
}
493470

494-
// The server write command specification states that lastOp is an optional
495-
// mongod only field that has a type of timestamp. Across various scarce specs
496-
// where opTime is mentioned, it is an "opaque" object that can have a "ts" and
497-
// "t" field with Timestamp and Long as their types respectively.
498-
// The "lastOp" field of the bulk write result is never mentioned in the driver
499-
// specifications or the bulk write spec, so we should probably just keep its
500-
// value consistent since it seems to vary.
501-
// See: https://github.com/mongodb/specifications/blob/master/source/driver-bulk-update.rst#results-object
502-
if (result.opTime || result.lastOp) {
503-
let opTime = result.lastOp || result.opTime;
504-
505-
// If the opTime is a Timestamp, convert it to a consistent format to be
506-
// able to compare easily. Converting to the object from a timestamp is
507-
// much more straightforward than the other direction.
508-
if (opTime._bsontype === 'Timestamp') {
509-
opTime = { ts: opTime, t: Long.ZERO };
510-
}
511-
512-
// If there's no lastOp, just set it.
513-
if (!bulkResult.opTime) {
514-
bulkResult.opTime = opTime;
515-
} else {
516-
// First compare the ts values and set if the opTimeTS value is greater.
517-
const lastOpTS = longOrConvert(bulkResult.opTime.ts);
518-
const opTimeTS = longOrConvert(opTime.ts);
519-
if (opTimeTS.greaterThan(lastOpTS)) {
520-
bulkResult.opTime = opTime;
521-
} else if (opTimeTS.equals(lastOpTS)) {
522-
// If the ts values are equal, then compare using the t values.
523-
const lastOpT = longOrConvert(bulkResult.opTime.t);
524-
const opTimeT = longOrConvert(opTime.t);
525-
if (opTimeT.greaterThan(lastOpT)) {
526-
bulkResult.opTime = opTime;
527-
}
528-
}
529-
}
530-
}
531-
532471
// If we have an insert Batch type
533472
if (isInsertBatch(batch) && result.n) {
534473
bulkResult.nInserted = bulkResult.nInserted + result.n;

src/cursor/abstract_cursor.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@ export const CURSOR_FLAGS = [
5858
'partial'
5959
] as const;
6060

61-
/** @public
62-
* @deprecated This interface is deprecated */
63-
export interface CursorCloseOptions {
64-
/** Bypass calling killCursors when closing the cursor. */
65-
/** @deprecated the skipKillCursors option is deprecated */
66-
skipKillCursors?: boolean;
67-
}
68-
6961
/** @public */
7062
export interface CursorStreamOptions {
7163
/** A transformation method applied to each document emitted by the stream */
@@ -447,18 +439,7 @@ export abstract class AbstractCursor<
447439
close(): Promise<void>;
448440
/** @deprecated Callbacks are deprecated and will be removed in the next major version. See [mongodb-legacy](https://github.com/mongodb-js/nodejs-mongodb-legacy) for migration assistance */
449441
close(callback: Callback): void;
450-
/**
451-
* @deprecated options argument is deprecated
452-
*/
453-
close(options: CursorCloseOptions): Promise<void>;
454-
/**
455-
* @deprecated options argument is deprecated. Callbacks are deprecated and will be removed in the next major version. See [mongodb-legacy](https://github.com/mongodb-js/nodejs-mongodb-legacy) for migration assistance
456-
*/
457-
close(options: CursorCloseOptions, callback: Callback): void;
458-
close(options?: CursorCloseOptions | Callback, callback?: Callback): Promise<void> | void {
459-
if (typeof options === 'function') (callback = options), (options = {});
460-
options = options ?? {};
461-
442+
close(callback?: Callback): Promise<void> | void {
462443
const needsToEmitClosed = !this[kClosed];
463444
this[kClosed] = true;
464445

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ export type { MONGO_CLIENT_EVENTS } from './constants';
257257
export type {
258258
AbstractCursorEvents,
259259
AbstractCursorOptions,
260-
CursorCloseOptions,
261260
CursorFlag,
262261
CursorStreamOptions
263262
} from './cursor/abstract_cursor';

test/unit/bulk/common.test.js

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)