-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
50 lines (44 loc) · 1.24 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
47
48
49
50
const mongoose = require('mongoose');
const dotenv = require("dotenv")
dotenv.config()
// PROD
mongoose.connect(process.env.DATABASE_URL);
// LOCAL/TEST
// mongoose.connect(process.env.TEST_DSN);
// layer schema (optional fields scale, author, text, and color)
const LayerSchema = new mongoose.Schema({
uniqueID: {
type: String,
required: true,
unique: true
},
graphicType: {
type: String,
required: true
},
layerAttributes: {
type: Object,
required: true
},
author: {
type: String,
required: true
}
}, {timestamps: true});
// by attatching timestamps to each layer when consecutive edits are made, the timestamp that is
// more recent will take precedence
// user shchema
const UserSchema = new mongoose.Schema({
username: {type: String, required: true},
color: {type: String}
// password: {type: String, required: true},
// email: {type: String, required: true},
});
// room shchema
const RoomSchema = new mongoose.Schema({
username: {type: String, required: true},
roomNumber: {type: String, required: true},
});
mongoose.model('Layer', LayerSchema);
mongoose.model('User', UserSchema);
mongoose.model('Room', RoomSchema);