Update mongodb and simplify the logic of mongodbPing
This commit is contained in:
parent
e48a987b9c
commit
1326761a8a
|
@ -39,7 +39,7 @@
|
|||
"jsonwebtoken": "~9.0.0",
|
||||
"jwt-decode": "~3.1.2",
|
||||
"limiter": "~2.1.0",
|
||||
"mongodb": "^4.12.0",
|
||||
"mongodb": "~4.13.0",
|
||||
"mqtt": "~4.3.7",
|
||||
"mssql": "~8.1.4",
|
||||
"mysql2": "~2.3.3",
|
||||
|
@ -13611,9 +13611,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/mongodb": {
|
||||
"version": "4.12.0",
|
||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.12.0.tgz",
|
||||
"integrity": "sha512-ssWod7DqVE4faluZESdOqYhV1BI5CQA5c31sr+zxDLJDBX9EA5VJLo8RNSItPTwxExmuGn/T6MbETQWjywNehA==",
|
||||
"version": "4.13.0",
|
||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.13.0.tgz",
|
||||
"integrity": "sha512-+taZ/bV8d1pYuHL4U+gSwkhmDrwkWbH1l4aah4YpmpscMwgFBkufIKxgP/G7m87/NUuQzc2Z75ZTI7ZOyqZLbw==",
|
||||
"dependencies": {
|
||||
"bson": "^4.7.0",
|
||||
"mongodb-connection-string-url": "^2.5.4",
|
||||
|
@ -28738,9 +28738,9 @@
|
|||
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
|
||||
},
|
||||
"mongodb": {
|
||||
"version": "4.12.0",
|
||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.12.0.tgz",
|
||||
"integrity": "sha512-ssWod7DqVE4faluZESdOqYhV1BI5CQA5c31sr+zxDLJDBX9EA5VJLo8RNSItPTwxExmuGn/T6MbETQWjywNehA==",
|
||||
"version": "4.13.0",
|
||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.13.0.tgz",
|
||||
"integrity": "sha512-+taZ/bV8d1pYuHL4U+gSwkhmDrwkWbH1l4aah4YpmpscMwgFBkufIKxgP/G7m87/NUuQzc2Z75ZTI7ZOyqZLbw==",
|
||||
"requires": {
|
||||
"@aws-sdk/credential-providers": "^3.186.0",
|
||||
"bson": "^4.7.0",
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
"jsonwebtoken": "~9.0.0",
|
||||
"jwt-decode": "~3.1.2",
|
||||
"limiter": "~2.1.0",
|
||||
"mongodb": "^4.12.0",
|
||||
"mongodb": "~4.13.0",
|
||||
"mqtt": "~4.3.7",
|
||||
"mssql": "~8.1.4",
|
||||
"mysql2": "~2.3.3",
|
||||
|
|
|
@ -325,22 +325,15 @@ exports.mysqlQuery = function (connectionString, query) {
|
|||
* @returns {Promise<(string[]|Object[]|Object)>}
|
||||
*/
|
||||
exports.mongodbPing = async function (connectionString) {
|
||||
let client;
|
||||
|
||||
try {
|
||||
client = await MongoClient.connect(connectionString, { useNewUrlParser: true });
|
||||
let db = client.db();
|
||||
let dbping = await db.command({ ping: 1 });
|
||||
let client = await MongoClient.connect(connectionString);
|
||||
let dbPing = await client.db().command({ ping: 1 });
|
||||
await client.close();
|
||||
if (dbping["ok"] === 1) {
|
||||
|
||||
if (dbPing["ok"] === 1) {
|
||||
return "UP";
|
||||
} else {
|
||||
throw Error("failed");
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw Error(err);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue