-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
31 lines (28 loc) · 814 Bytes
/
db.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
const mongoose = require('mongoose');
const playerSchema = mongoose.Schema({
_id: String,
name: { type: String, unique: true },
wins: Number,
losses: Number,
elo: Number,
});
const installSchema = mongoose.Schema({
_id: String,
installation: Object,
});
// Connect to mongodb
module.exports = {
connectToDb: () => {
const mongoPass = process.env.MONGOPASS;
const mongoUser = process.env.MONGOUSER;
const uri = `mongodb+srv://${mongoUser}:${mongoPass}@cluster0.a73d5.mongodb.net/kingpong?retryWrites=true&w=majority`;
mongoose.connect(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: true,
useCreateIndex: true,
});
},
Player: mongoose.model('Player', playerSchema),
Install: mongoose.model('Install', installSchema),
};