From 2e28009892cca6db9564fba9822a321f7900f44b Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Tue, 3 Jan 2023 21:31:33 +0100 Subject: [PATCH] feat(NODE-3818)!: remove slaveOk options (#3503) --- etc/notes/CHANGES_5.0.0.md | 5 +++++ src/collection.ts | 4 ---- src/db.ts | 8 -------- src/read_preference.ts | 9 --------- test/unit/db.test.ts | 6 ------ test/unit/read_preference.test.ts | 5 ----- 6 files changed, 5 insertions(+), 32 deletions(-) diff --git a/etc/notes/CHANGES_5.0.0.md b/etc/notes/CHANGES_5.0.0.md index cd61bf8cf5..924069b319 100644 --- a/etc/notes/CHANGES_5.0.0.md +++ b/etc/notes/CHANGES_5.0.0.md @@ -16,6 +16,11 @@ The following is a detailed collection of the changes in the major v5 release of ## Changes +### salveOk options removed + +The deprecated `slaveOk` option and `slaveOk()` method on the `Collection` class have been removed. Please +now use `secondaryOk` as the replacement for the option and the method. + ### Bulk results no longer contain `lastOp()` and `opTime` The `lastOp()` method and `opTime` property on the `BulkResult` have been removed. Merging of bulk results diff --git a/src/collection.ts b/src/collection.ts index d61ffcb285..fb02e21101 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -116,10 +116,6 @@ export interface CollectionOptions extends BSONSerializeOptions, WriteConcernOptions, LoggerOptions { - /** - * @deprecated Use readPreference instead - */ - slaveOk?: boolean; /** Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) */ readConcern?: ReadConcernLike; /** The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). */ diff --git a/src/db.ts b/src/db.ts index 73918d6d8f..29f97fb772 100644 --- a/src/db.ts +++ b/src/db.ts @@ -184,14 +184,6 @@ export class Db { return this.s.options; } - /** - * slaveOk specified - * @deprecated Use secondaryOk instead - */ - get slaveOk(): boolean { - return this.secondaryOk; - } - /** * Check if a secondary can be used (because the read preference is *not* set to primary) */ diff --git a/src/read_preference.ts b/src/read_preference.ts index b7210b8e6c..1f3d2d0c86 100644 --- a/src/read_preference.ts +++ b/src/read_preference.ts @@ -227,15 +227,6 @@ export class ReadPreference { return ReadPreference.isValid(typeof mode === 'string' ? mode : this.mode); } - /** - * Indicates that this readPreference needs the "secondaryOk" bit when sent over the wire - * @deprecated Use secondaryOk instead - * @see https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#op-query - */ - slaveOk(): boolean { - return this.secondaryOk(); - } - /** * Indicates that this readPreference needs the "SecondaryOk" bit when sent over the wire * @see https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#op-query diff --git a/test/unit/db.test.ts b/test/unit/db.test.ts index 48dfbb527e..f3620403ad 100644 --- a/test/unit/db.test.ts +++ b/test/unit/db.test.ts @@ -7,7 +7,6 @@ import { ReadPreference } from '../../src/read_preference'; describe('class Db', function () { describe('secondaryOk', function () { const client = new MongoClient('mongodb://localhost:27017'); - const legacy_secondary_ok = 'slaveOk'; const secondary_ok = 'secondaryOk'; it('should be false when readPreference is Primary', function () { @@ -15,7 +14,6 @@ describe('class Db', function () { const mydb = new Db(client, 'mydb', options); expect(mydb).property(secondary_ok).to.be.false; - expect(mydb).property(legacy_secondary_ok).to.be.false; }); it('should be true when readPreference is Primary Preferred', function () { @@ -23,7 +21,6 @@ describe('class Db', function () { const mydb = new Db(client, 'mydb', options); expect(mydb).property(secondary_ok).to.be.true; - expect(mydb).property(legacy_secondary_ok).to.be.true; }); it('should be true when readPreference is Secondary', function () { @@ -31,7 +28,6 @@ describe('class Db', function () { const mydb = new Db(client, 'mydb', options); expect(mydb).property(secondary_ok).to.be.true; - expect(mydb).property(legacy_secondary_ok).to.be.true; }); it('should be true when readPreference is Secondary Preferred', function () { @@ -39,7 +35,6 @@ describe('class Db', function () { const mydb = new Db(client, 'mydb', options); expect(mydb).property(secondary_ok).to.be.true; - expect(mydb).property(legacy_secondary_ok).to.be.true; }); it('should be true when readPreference is Nearest', function () { @@ -47,7 +42,6 @@ describe('class Db', function () { const mydb = new Db(client, 'mydb', options); expect(mydb).property(secondary_ok).to.be.true; - expect(mydb).property(legacy_secondary_ok).to.be.true; }); }); }); diff --git a/test/unit/read_preference.test.ts b/test/unit/read_preference.test.ts index 1d96821485..a569cc4e98 100644 --- a/test/unit/read_preference.test.ts +++ b/test/unit/read_preference.test.ts @@ -139,7 +139,6 @@ describe('class ReadPreference', function () { readPreference: PRIMARY }); expect(readPreference.secondaryOk()).to.be.false; - expect(readPreference.slaveOk()).to.be.false; }); it('should be true when readPreference is Primary Preferred', function () { @@ -147,7 +146,6 @@ describe('class ReadPreference', function () { readPreference: PRIMARY_PREFERRED }); expect(readPreference.secondaryOk()).to.be.true; - expect(readPreference.slaveOk()).to.be.true; }); it('should be true when readPreference is Secondary', function () { @@ -155,7 +153,6 @@ describe('class ReadPreference', function () { readPreference: SECONDARY }); expect(readPreference.secondaryOk()).to.be.true; - expect(readPreference.slaveOk()).to.be.true; }); it('should be true when readPreference is Secondary Preferred', function () { @@ -163,7 +160,6 @@ describe('class ReadPreference', function () { readPreference: SECONDARY_PREFERRED }); expect(readPreference.secondaryOk()).to.be.true; - expect(readPreference.slaveOk()).to.be.true; }); it('should be true when readPreference is Nearest', function () { @@ -171,7 +167,6 @@ describe('class ReadPreference', function () { readPreference: NEAREST }); expect(readPreference.secondaryOk()).to.be.true; - expect(readPreference.slaveOk()).to.be.true; }); }); });