Skip to content

Commit f47685b

Browse files
committed
feat: simplify connection overrides
1 parent 3689a61 commit f47685b

File tree

3 files changed

+4470
-8
lines changed

3 files changed

+4470
-8
lines changed

lib/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,9 @@ DataStore.prototype.getConnectionOptions = function (overrideOptions) {
495495
(overrideOptions.database &&
496496
overrideOptions.database !== connectionOptions.databaase)
497497

498-
// override ok and config block exists with the specified database key
499-
if (allowOverride && this.config[overrideOptions.database]) {
500-
connectionOptions = Object.assign(connectionOptions, { database: overrideOptions.database }, this.config[overrideOptions.database])
501-
} else if (allowOverride && typeof this.config[overrideOptions.database] === 'undefined') {
502-
throw new Error(`Requested database "${overrideOptions.database}" is not configured`)
498+
// override allowed, use defaults or config block if one exists for the specified database key
499+
if (allowOverride) {
500+
connectionOptions = Object.assign(connectionOptions, { database: overrideOptions.database }, this.config.databases[overrideOptions.database])
503501
}
504502

505503
debug('connectionOptions %o', connectionOptions)

0 commit comments

Comments
 (0)