Skip to content

Commit d2a1e75

Browse files
committed
two options inheritance fixes in Db
1 parent 416d3ce commit d2a1e75

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/db.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ export class Db implements OperationParent {
172172
logger: new Logger('Db', options),
173173
// Unpack read preference
174174
readPreference: ReadPreference.fromOptions(options),
175-
// Merge bson options TODO: include client bson options, after NODE-2850
176-
bsonOptions: resolveBSONOptions(options),
175+
// Merge bson options
176+
bsonOptions: resolveBSONOptions(options, client),
177177
// Set up the primary key factory or fallback to ObjectId
178178
pkFactory: options?.pkFactory ?? {
179179
createPk() {
@@ -208,14 +208,17 @@ export class Db implements OperationParent {
208208
return this.s.readPreference?.preference !== 'primary' || false;
209209
}
210210

211+
/**
212+
* The current readPreference of the Db. If not explicitly defined for
213+
* this Db, will be inherited from the parent MongoClient
214+
*/
211215
get readConcern(): ReadConcern | undefined {
212216
return this.s.readConcern;
213217
}
214218

215219
get readPreference(): ReadPreference {
216220
if (this.s.readPreference == null) {
217-
// TODO: check client
218-
return ReadPreference.primary;
221+
return this.s.client.readPreference;
219222
}
220223

221224
return this.s.readPreference;

0 commit comments

Comments
 (0)