Skip to content

Commit 3304196

Browse files
committed
chore: remove db from collection private
1 parent ccc4155 commit 3304196

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/bulk/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ export abstract class BulkOperationBase {
900900

901901
// Final options for retryable writes
902902
let finalOptions = Object.assign({}, options);
903-
finalOptions = applyRetryableWrites(finalOptions, collection.s.db);
903+
finalOptions = applyRetryableWrites(finalOptions, collection.db);
904904

905905
// Final results
906906
const bulkResult: BulkResult = {
@@ -1228,7 +1228,7 @@ export abstract class BulkOperationBase {
12281228
private shouldForceServerObjectId(): boolean {
12291229
return (
12301230
this.s.options.forceServerObjectId === true ||
1231-
this.s.collection.s.db.options?.forceServerObjectId === true
1231+
this.s.collection.db.options?.forceServerObjectId === true
12321232
);
12331233
}
12341234
}

src/collection.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export class Collection<TSchema extends Document = Document> {
234234
*/
235235
get readConcern(): ReadConcern | undefined {
236236
if (this.s.readConcern == null) {
237-
return this.s.db.readConcern;
237+
return this.db.readConcern;
238238
}
239239
return this.s.readConcern;
240240
}
@@ -245,7 +245,7 @@ export class Collection<TSchema extends Document = Document> {
245245
*/
246246
get readPreference(): ReadPreference | undefined {
247247
if (this.s.readPreference == null) {
248-
return this.s.db.readPreference;
248+
return this.db.readPreference;
249249
}
250250

251251
return this.s.readPreference;
@@ -261,7 +261,7 @@ export class Collection<TSchema extends Document = Document> {
261261
*/
262262
get writeConcern(): WriteConcern | undefined {
263263
if (this.s.writeConcern == null) {
264-
return this.s.db.writeConcern;
264+
return this.db.writeConcern;
265265
}
266266
return this.s.writeConcern;
267267
}
@@ -515,7 +515,7 @@ export class Collection<TSchema extends Document = Document> {
515515
* @param options - Optional settings for the command
516516
*/
517517
async drop(options?: DropCollectionOptions): Promise<boolean> {
518-
return await this.s.db.dropCollection(this.collectionName, options);
518+
return await this.db.dropCollection(this.collectionName, options);
519519
}
520520

521521
/**
@@ -584,7 +584,7 @@ export class Collection<TSchema extends Document = Document> {
584584
*/
585585
async options(options?: OperationOptions): Promise<Document> {
586586
options = resolveOptions(this, options);
587-
const [collection] = await this.s.db
587+
const [collection] = await this.db
588588
.listCollections({ name: this.collectionName }, { ...options, nameOnly: false })
589589
.toArray();
590590

src/operations/rename.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class RenameOperation extends CommandOperation<Document> {
4848
}
4949

5050
override handleOk(_response: InstanceType<typeof this.SERVER_COMMAND_RESPONSE_TYPE>): Document {
51-
return new Collection(this.collection.s.db, this.newName, this.collection.s.options);
51+
return new Collection(this.collection.db, this.newName, this.collection.s.options);
5252
}
5353
}
5454

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ export function maybeAddIdToDocuments(
13621362
options: { forceServerObjectId?: boolean }
13631363
): Document {
13641364
const forceServerObjectId =
1365-
options.forceServerObjectId ?? collection.s.db.options?.forceServerObjectId ?? false;
1365+
options.forceServerObjectId ?? collection.db.options?.forceServerObjectId ?? false;
13661366

13671367
// no need to modify the docs if server sets the ObjectId
13681368
if (forceServerObjectId) {

0 commit comments

Comments
 (0)