Update mongodb.js
简化代码
This commit is contained in:
parent
4daac0781f
commit
56c4a37f6d
@ -4,9 +4,7 @@ const mongoose = require('mongoose')
|
|||||||
const schema = require('./schema')
|
const schema = require('./schema')
|
||||||
|
|
||||||
// the default mongodb url (local server)
|
// the default mongodb url (local server)
|
||||||
let mongodbURL = `mongodb://127.0.0.1:27017`
|
const mongodbURL = process.env.DB_URL || 'mongodb://127.0.0.1:27017'
|
||||||
const envMongoURL = process.env.DB_URL
|
|
||||||
if (envMongoURL) mongodbURL = envMongoURL
|
|
||||||
|
|
||||||
mongoose.connect(mongodbURL, {
|
mongoose.connect(mongodbURL, {
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
@ -38,4 +36,4 @@ module.exports = {
|
|||||||
getNum,
|
getNum,
|
||||||
getAll,
|
getAll,
|
||||||
setNum
|
setNum
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user