@bluedot-innovation/models 7.16.1 → 7.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/package.json +3 -3
- package/utils/DbInitialiser/DbInitialiser.js +13 -8
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluedot-innovation/models",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.17.0",
|
|
4
4
|
"main": "Models.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"eslint-plugin-promise": "^3.6.0",
|
|
24
24
|
"eslint-plugin-standard": "^3.0.1",
|
|
25
25
|
"mocha": "^4.0.1",
|
|
26
|
-
"mongodb": "^
|
|
26
|
+
"mongodb": "^5.1.0",
|
|
27
27
|
"nyc": "^11.3.0",
|
|
28
28
|
"prettier": "^1.13.5",
|
|
29
29
|
"sinon": "^4.1.2"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"deep-equal": "^1.0.1",
|
|
38
38
|
"fast-deep-equal": "^2.0.1",
|
|
39
39
|
"lodash.clonedeep": "4.5.0",
|
|
40
|
-
"mongoose": "^
|
|
40
|
+
"mongoose": "^6.10.4",
|
|
41
41
|
"uuid": "^3.1.0"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -4,26 +4,31 @@ const {createAllIndexesIfNotExists} = require("./indexInitialiser");
|
|
|
4
4
|
const MONGO_DB_URI = process.env.MONGO_DB_URI
|
|
5
5
|
const DB_NAME = process.env.DB_NAME
|
|
6
6
|
const ENVIRONMENT = process.env.ENVIRONMENT
|
|
7
|
-
const client = new MongoClient(MONGO_DB_URI
|
|
7
|
+
const client = new MongoClient(MONGO_DB_URI)
|
|
8
8
|
|
|
9
9
|
console.log(`Using DB_NAME:${DB_NAME} in ENVIRONMENT:${ENVIRONMENT}`)
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const dbInitialiser = async () => {
|
|
12
|
+
try {
|
|
13
|
+
await client.connect()
|
|
14
|
+
} catch (error) {
|
|
13
15
|
console.log("Failed to connect to Mongo DB", error)
|
|
14
16
|
process.exit(1)
|
|
15
17
|
}
|
|
18
|
+
|
|
16
19
|
console.log("Connected to Mongo DB")
|
|
17
|
-
|
|
20
|
+
|
|
18
21
|
const db = client.db(DB_NAME)
|
|
19
|
-
|
|
22
|
+
|
|
20
23
|
try{
|
|
21
24
|
await createAllIndexesIfNotExists(db)
|
|
22
|
-
}catch(error){
|
|
25
|
+
} catch(error) {
|
|
23
26
|
console.log(error)
|
|
24
27
|
await client.close()
|
|
25
28
|
process.exit(1)
|
|
26
29
|
}
|
|
27
|
-
|
|
30
|
+
|
|
28
31
|
await client.close()
|
|
29
|
-
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
dbInitialiser()
|