-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.js
35 lines (32 loc) · 838 Bytes
/
database.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const mongoose = require("mongoose");
const debug = require("debug")("app:database");
const server = "127.0.0.1:27017";
const database = "bookAPI";
const testDatabase = "bookAPI_Test"
class Database {
constructor() {
}
_connect() {
mongoose
.connect(`mongodb://${server}/${database}`)
.then(() => {
debug("Database connection successful");
})
// eslint-disable-next-line no-unused-vars
.catch((err) => {
debug(`Database connection error is ${err}`);
});
}
_test(){
mongoose
.connect(`mongodb://${server}/${testDatabase}`)
.then(() => {
debug("Database connection successful");
})
// eslint-disable-next-line no-unused-vars
.catch((err) => {
debug(`dtabase connection error is ${err}`);
});
}
}
module.exports = new Database();