Skip to content

Commit

Permalink
Fix getAdapter key check using getInterfaceName() method
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinegomez authored and Antoine Gomez committed Jan 15, 2018
1 parent 6a6db80 commit 40299e3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hapiness/mongo",
"version": "1.1.2",
"version": "1.1.3",
"description": "Hapiness Module for MongoDB usage",
"main": "commonjs/index.js",
"types": "index.d.ts",
Expand Down Expand Up @@ -64,7 +64,8 @@
"url": "https://github.com/njl07"
}
],
"license": "SEE LICENSE IN https://github.com/hapinessjs/mongo-module/blob/master/LICENSE.md",
"license":
"SEE LICENSE IN https://github.com/hapinessjs/mongo-module/blob/master/LICENSE.md",
"bugs": {
"url": "https://github.com/hapinessjs/mongo-module/issues"
},
Expand Down
8 changes: 7 additions & 1 deletion src/module/managers/mongo-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ export class MongoManager {

// If there is only one registered provider for the wanted adapter, dont compute the key but return it directly
let key = '';
const _keysForAdapterInstances = Object.keys(this._adaptersInstances).filter(k => k.indexOf(adapterName) !== -1);
const _keysForAdapterInstances = Object.entries(this._adaptersInstances)
.filter(
([k, v]) =>
(<typeof HapinessMongoAdapter>v.constructor).getInterfaceName() === adapterName
)
.map(([k]) => k);

if (_keysForAdapterInstances.length === 1) {
key = _keysForAdapterInstances.shift();
} else {
Expand Down
18 changes: 3 additions & 15 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,10 @@
"rootDir": ".",
"skipLibCheck": true,
"typeRoots": ["./node_modules/@types"],
"types": [
"node",
"fs-extra",
"mongoose",
"gridfs-stream"
],
"lib": [
"dom",
"es2015"
]
"types": ["node", "fs-extra", "mongoose", "gridfs-stream"],
"lib": ["dom", "es2015", "es2016", "es2017"]
},
"compileOnSave": false,
"buildOnSave": false,
"exclude": [
"node_modules",
"dist",
"tmp"
]
"exclude": ["node_modules", "dist", "tmp"]
}

0 comments on commit 40299e3

Please sign in to comment.