aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJad <[email protected]>2020-08-22 20:36:34 +0800
committerGitHub <[email protected]>2020-08-22 20:36:34 +0800
commit56c4a37f6dced77f785740b55d2b104071f6907f (patch)
treed41d8a325c19ea19ec20ac648b8fccba3bb4e386
parentadd return json data REST api (diff)
downloadcounter-56c4a37f6dced77f785740b55d2b104071f6907f.tar.xz
counter-56c4a37f6dced77f785740b55d2b104071f6907f.zip
Update mongodb.js
简化代码
-rw-r--r--db/mongodb.js6
1 files changed, 2 insertions, 4 deletions
diff --git a/db/mongodb.js b/db/mongodb.js
index 40f7695..57f1b72 100644
--- a/db/mongodb.js
+++ b/db/mongodb.js
@@ -4,9 +4,7 @@ const mongoose = require('mongoose')
const schema = require('./schema')
// the default mongodb url (local server)
-let mongodbURL = `mongodb://127.0.0.1:27017`
-const envMongoURL = process.env.DB_URL
-if (envMongoURL) mongodbURL = envMongoURL
+const mongodbURL = process.env.DB_URL || 'mongodb://127.0.0.1:27017'
mongoose.connect(mongodbURL, {
useNewUrlParser: true,
@@ -38,4 +36,4 @@ module.exports = {
getNum,
getAll,
setNum
-} \ No newline at end of file
+}