33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const mongoose = require('mongoose')
|
|
|
|
mongoose.plugin(schema => {
|
|
schema.set('toObject', {
|
|
getters: true
|
|
})
|
|
schema.set('toJSON', {
|
|
getters: true
|
|
})
|
|
schema.set('timestamps', {
|
|
createdAt: 'created_at',
|
|
updatedAt: 'updated_at'
|
|
})
|
|
})
|
|
|
|
// 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.
|
|
// mongoose.connect('mongodb://negareh1_admin:admin1234@www.negareh-demo.ir:27017/negareh1_oris?serverSelectionTimeoutMS=5000&connectTimeoutMS=10000&authSource=negareh1_oris', {
|
|
mongoose.connect('mongodb://root:UuPYfG7G6pFqWLW0gOya9oYt@grande-casse.liara.cloud:32644/orisoxin?authSource=admin', {
|
|
// mongoose.connect('mongodb://localhost:27017/OrisOxin', {
|
|
useNewUrlParser: true,
|
|
useUnifiedTopology: true,
|
|
useFindAndModify: false,
|
|
useCreateIndex: true
|
|
})
|
|
|
|
const database = mongoose.connection
|
|
database.on('error', console.error.bind(console, 'connection error:'))
|
|
database.once('open', function callback() {
|
|
console.log("MongoDB Connected...")
|
|
})
|
|
|
|
module.exports = database
|