Skip to content

Commit 2199194

Browse files
committed
clean up
1 parent 5427509 commit 2199194

File tree

4 files changed

+3
-74
lines changed

4 files changed

+3
-74
lines changed

src/collection.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,7 @@ export class Collection implements OperationParent {
567567
if (typeof options === 'function') (callback = options), (options = {});
568568

569569
// Intentionally, we do not inherit options from parent for this operation.
570-
options = options || {};
571-
options.readPreference = ReadPreference.PRIMARY;
570+
options = Object.assign({}, options, { readPreference: ReadPreference.PRIMARY });
572571
return executeOperation(
573572
getTopology(this),
574573
new RenameOperation(this, newName, options),
@@ -1317,7 +1316,7 @@ export class Collection implements OperationParent {
13171316
/** Initiate an In order bulk write operation. Operations will be serially executed in the order they are added, creating a new operation for each switch in types. */
13181317
initializeOrderedBulkOp(options?: BulkWriteOptions): any {
13191318
options = options || {};
1320-
// Give function's options precedence over session options.
1319+
// Give function's options precedence over session's options.
13211320
if (options.ignoreUndefined == null) {
13221321
options.ignoreUndefined = this.bsonOptions.ignoreUndefined;
13231322
}

src/db.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,7 @@ export class Db implements OperationParent {
459459
if (typeof options === 'function') (callback = options), (options = {});
460460

461461
// Intentionally, we do not inherit options from parent for this operation.
462-
options = options || {};
463-
options.readPreference = ReadPreference.PRIMARY;
462+
options = Object.assign({}, options, { readPreference: ReadPreference.PRIMARY });
464463

465464
// Add return new collection
466465
options.new_collection = true;

src/read_preference.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -163,36 +163,6 @@ export class ReadPreference {
163163
return readPreference as ReadPreference;
164164
}
165165

166-
// /**
167-
// * Resolves a read preference based on well-defined inheritance rules. This method will not only
168-
// * determine the read preference (if there is one), but will also ensure the returned value is a
169-
// * properly constructed instance of `ReadPreference`.
170-
// *
171-
// * @param parent - The parent of the operation on which to determine the read preference, used for determining the inherited read preference.
172-
// * @param options - The options passed into the method, potentially containing a read preference
173-
// */
174-
// static resolve(parent?: OperationParent, options?: ReadPreferenceFromOptions): ReadPreference {
175-
// options = options || {};
176-
// const session = options.session;
177-
178-
// const inheritedReadPreference = parent?.readPreference;
179-
180-
// let readPreference: ReadPreference = ReadPreference.primary;
181-
// if (options.readPreference) {
182-
// const readPrefFromOptions = ReadPreference.fromOptions(options);
183-
// readPreference = readPrefFromOptions ? readPrefFromOptions : readPreference;
184-
// } else if (session && session.inTransaction() && session.transaction.options.readPreference) {
185-
// // The transaction’s read preference MUST override all other user configurable read preferences.
186-
// readPreference = session.transaction.options.readPreference;
187-
// } else if (inheritedReadPreference != null) {
188-
// readPreference = inheritedReadPreference;
189-
// }
190-
191-
// return typeof readPreference === 'string'
192-
// ? new ReadPreference(readPreference as ReadPreferenceMode)
193-
// : readPreference;
194-
// }
195-
196166
/**
197167
* Replaces options.readPreference with a ReadPreference instance
198168
*/

src/utils.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -215,45 +215,6 @@ export function filterOptions(options: AnyOptions, names: string[]): AnyOptions
215215
return filterOptions;
216216
}
217217

218-
// /** @internal */
219-
// export function mergeOptionsAndWriteConcern(
220-
// targetOptions: AnyOptions,
221-
// sourceOptions: AnyOptions,
222-
// keys: string[]
223-
// ): AnyOptions {
224-
// // Mix in any allowed options
225-
// for (let i = 0; i < keys.length; i++) {
226-
// if (targetOptions[keys[i]] === undefined && sourceOptions[keys[i]] !== undefined) {
227-
// targetOptions[keys[i]] = sourceOptions[keys[i]];
228-
// }
229-
// }
230-
231-
// // todo could do this with an object.assign and then pluck the keys, except this doesn't work w mergeWriteconcern
232-
// // but we always set that to true so we're good!
233-
234-
// // Found no write Concern options
235-
// let found = false;
236-
// for (let i = 0; i < writeConcernKeys.length; i++) {
237-
// if (targetOptions[writeConcernKeys[i]]) {
238-
// found = true;
239-
// break;
240-
// }
241-
// }
242-
243-
// // merge write concern keys iff none are found
244-
// if (!found) {
245-
// for (let i = 0; i < writeConcernKeys.length; i++) {
246-
// if (sourceOptions[writeConcernKeys[i]]) {
247-
// targetOptions[writeConcernKeys[i]] = sourceOptions[writeConcernKeys[i]];
248-
// }
249-
// }
250-
// }
251-
252-
// results = resolveInheritedOptions(this, options);
253-
254-
// return targetOptions;
255-
// }
256-
257218
/**
258219
* Executes the given operation with provided arguments.
259220
*

0 commit comments

Comments
 (0)