Update database.js
This commit is contained in:
+9
-5
@@ -1,20 +1,24 @@
|
|||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
const mongoose = require('mongoose')
|
const mongoose = require('mongoose')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// mongodb database connection string. change it as per your needs. here "mydb" is the name of the database. You don't need to create DB from mongodb terminal. mongoose create the database automatically.
|
// mongodb database connection string. change it as per your needs. here "mydb" is the name of the database. You don't need to create DB from mongodb terminal. mongoose create the database automatically.
|
||||||
const inHostUrl = 'mongodb://asanserv_admin:admin1234@localhost:27017/asanserv_database'
|
const inHostUrl = 'mongodb://asanserv_admin:admin1234@localhost:27017/asanserv_database'
|
||||||
const outHostUrl =
|
const outHostUrl =
|
||||||
'mongodb://asanserv_admin:admin1234@www.asan-service.com:27017/asanserv_database?serverSelectionTimeoutMS=5000&connectTimeoutMS=10000&authSource=asanserv_database'
|
'mongodb://asanserv_admin:admin1234@www.asan-service.com:27017/asanserv_database?serverSelectionTimeoutMS=5000&connectTimeoutMS=10000&authSource=asanserv_database'
|
||||||
const locaUrl = 'mongodb://localhost:27017/AsanService'
|
const locaUrl = 'mongodb://localhost:27017/AsanService'
|
||||||
mongoose.connect(outHostUrl, {
|
const init = ()=>{
|
||||||
|
try {
|
||||||
|
mongoose.connect(outHostUrl, {
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
useUnifiedTopology: true,
|
useUnifiedTopology: true,
|
||||||
useFindAndModify: false,
|
useFindAndModify: false,
|
||||||
useCreateIndex: true
|
useCreateIndex: true
|
||||||
})
|
})
|
||||||
|
} catch (error) {
|
||||||
|
init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init()
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
schema.set('toObject', { getters: true })
|
schema.set('toObject', { getters: true })
|
||||||
schema.set('toJSON', { getters: true })
|
schema.set('toJSON', { getters: true })
|
||||||
|
|||||||
Reference in New Issue
Block a user