Skip to content

Commit

Permalink
feat: simplify connection overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlambie committed Dec 4, 2017
1 parent 3689a61 commit f47685b
Show file tree
Hide file tree
Showing 3 changed files with 4,470 additions and 8 deletions.
8 changes: 3 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,9 @@ DataStore.prototype.getConnectionOptions = function (overrideOptions) {
(overrideOptions.database &&
overrideOptions.database !== connectionOptions.databaase)

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

debug('connectionOptions %o', connectionOptions)
Expand Down
Loading

0 comments on commit f47685b

Please sign in to comment.