@@ -172,11 +172,17 @@ export class Collection<TSchema extends Document = Document> {
172172 /** @internal */
173173 client : MongoClient ;
174174
175+ /**
176+ * Get the database object for the collection.
177+ */
178+ readonly db : Db ;
179+
175180 /**
176181 * Create a new Collection instance
177182 * @internal
178183 */
179184 constructor ( db : Db , name : string , options ?: CollectionOptions ) {
185+ this . db = db ;
180186 // Internal state
181187 this . s = {
182188 db,
@@ -228,7 +234,7 @@ export class Collection<TSchema extends Document = Document> {
228234 */
229235 get readConcern ( ) : ReadConcern | undefined {
230236 if ( this . s . readConcern == null ) {
231- return this . s . db . readConcern ;
237+ return this . db . readConcern ;
232238 }
233239 return this . s . readConcern ;
234240 }
@@ -239,7 +245,7 @@ export class Collection<TSchema extends Document = Document> {
239245 */
240246 get readPreference ( ) : ReadPreference | undefined {
241247 if ( this . s . readPreference == null ) {
242- return this . s . db . readPreference ;
248+ return this . db . readPreference ;
243249 }
244250
245251 return this . s . readPreference ;
@@ -255,7 +261,7 @@ export class Collection<TSchema extends Document = Document> {
255261 */
256262 get writeConcern ( ) : WriteConcern | undefined {
257263 if ( this . s . writeConcern == null ) {
258- return this . s . db . writeConcern ;
264+ return this . db . writeConcern ;
259265 }
260266 return this . s . writeConcern ;
261267 }
@@ -509,7 +515,7 @@ export class Collection<TSchema extends Document = Document> {
509515 * @param options - Optional settings for the command
510516 */
511517 async drop ( options ?: DropCollectionOptions ) : Promise < boolean > {
512- return await this . s . db . dropCollection ( this . collectionName , options ) ;
518+ return await this . db . dropCollection ( this . collectionName , options ) ;
513519 }
514520
515521 /**
@@ -578,7 +584,7 @@ export class Collection<TSchema extends Document = Document> {
578584 */
579585 async options ( options ?: OperationOptions ) : Promise < Document > {
580586 options = resolveOptions ( this , options ) ;
581- const [ collection ] = await this . s . db
587+ const [ collection ] = await this . db
582588 . listCollections ( { name : this . collectionName } , { ...options , nameOnly : false } )
583589 . toArray ( ) ;
584590
0 commit comments