-
Notifications
You must be signed in to change notification settings - Fork 1
/
db.js
46 lines (38 loc) · 1.12 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Config
var properties = require('./properties.json');
var auth = require('./auth.js');
// Mongo Code
var mongoose = require('mongoose');
// Mongoose Schema definition
var userSchema = new mongoose.Schema({
steamId: String,
discordId: String,
name: String,
platform: Number
});
var seasonStatSchema = new mongoose.Schema({
discordId: String,
data: Object
});
// Mongo access objects:
User = mongoose.model('UsersDB', userSchema);
Season = mongoose.model('SeasonStatsDB', seasonStatSchema);
var uri = "mongodb://"
+ properties.mongo_user + ":" + auth.getAuth('mongo') + "@"
+ "rldiscordbot-shard-00-00-k9ogi.mongodb.net:27017"
+ ",rldiscordbot-shard-00-01-k9ogi.mongodb.net:27017"
+ ",rldiscordbot-shard-00-02-k9ogi.mongodb.net:27017"
+ "/" + properties.mongo_db
+ "?ssl=true&replicaSet=RLDiscordBot-shard-0&authSource=admin"
;
function connect() {
mongoose.connect(uri, function (err) {
if (err) console.error(err);
else console.log('mongo connected');
});
}
module.exports = {
User: User,
Season: Season,
connect: connect,
};