@@ -129,6 +129,7 @@ export interface CollectionOptions extends BSONSerializeOptions, WriteConcernOpt
129129/** @internal */
130130export interface CollectionPrivate {
131131 pkFactory : PkFactory ;
132+ db : Db ;
132133 options : any ;
133134 namespace : MongoDBCollectionNamespace ;
134135 readPreference ?: ReadPreference ;
@@ -184,6 +185,7 @@ export class Collection<TSchema extends Document = Document> {
184185 this . db = db ;
185186 // Internal state
186187 this . s = {
188+ db,
187189 options,
188190 namespace : new MongoDBCollectionNamespace ( db . databaseName , name ) ,
189191 pkFactory : db . options ?. pkFactory ?? DEFAULT_PK_FACTORY ,
@@ -232,7 +234,7 @@ export class Collection<TSchema extends Document = Document> {
232234 */
233235 get readConcern ( ) : ReadConcern | undefined {
234236 if ( this . s . readConcern == null ) {
235- return this . db . readConcern ;
237+ return this . s . db . readConcern ;
236238 }
237239 return this . s . readConcern ;
238240 }
@@ -243,7 +245,7 @@ export class Collection<TSchema extends Document = Document> {
243245 */
244246 get readPreference ( ) : ReadPreference | undefined {
245247 if ( this . s . readPreference == null ) {
246- return this . db . readPreference ;
248+ return this . s . db . readPreference ;
247249 }
248250
249251 return this . s . readPreference ;
@@ -259,7 +261,7 @@ export class Collection<TSchema extends Document = Document> {
259261 */
260262 get writeConcern ( ) : WriteConcern | undefined {
261263 if ( this . s . writeConcern == null ) {
262- return this . db . writeConcern ;
264+ return this . s . db . writeConcern ;
263265 }
264266 return this . s . writeConcern ;
265267 }
@@ -513,7 +515,7 @@ export class Collection<TSchema extends Document = Document> {
513515 * @param options - Optional settings for the command
514516 */
515517 async drop ( options ?: DropCollectionOptions ) : Promise < boolean > {
516- return await this . db . dropCollection ( this . collectionName , options ) ;
518+ return await this . s . db . dropCollection ( this . collectionName , options ) ;
517519 }
518520
519521 /**
@@ -582,7 +584,7 @@ export class Collection<TSchema extends Document = Document> {
582584 */
583585 async options ( options ?: OperationOptions ) : Promise < Document > {
584586 options = resolveOptions ( this , options ) ;
585- const [ collection ] = await this . db
587+ const [ collection ] = await this . s . db
586588 . listCollections ( { name : this . collectionName } , { ...options , nameOnly : false } )
587589 . toArray ( ) ;
588590
0 commit comments