This repository has been archived by the owner on Oct 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.js
51 lines (45 loc) · 1.46 KB
/
models.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
51
'use strict';
let mongoose = require('mongoose');
let Schema = mongoose.Schema
,ObjectId = Schema.ObjectId;
module.exports.User = mongoose.model('User'
,new Schema({
id: ObjectId
,oauthID: {type: Number, unique: true}
,username: {type: String, required: '{PATH} is required.', unique: true}
,email: {type: String, unique: true}
,password: {type: String}
,settings: {type: [Schema.Types.Mixed], required: '{PATH} is required.'}
})
,'user'
);
module.exports.Folder = mongoose.model('Folder'
,new Schema({
id: ObjectId
,userid: {type: ObjectId, required: '{PATH} is required.', ref: 'User'}
,name: {type: String, required: '{PATH} is required.'}
,active: {type: Boolean, required: '{PATH} is required.', default: true}
,posts: [{type: ObjectId, ref: 'Post'}]
})
,'folder'
);
module.exports.Post = mongoose.model('Post'
,new Schema({
id: ObjectId
,userid: {type: ObjectId, required: '{PATH} is required.', ref: 'User'}
,folderid: {type: ObjectId, required: '{PATH} is required.', ref: 'Folder'}
,datetime: {type: Date, required: '{PATH} is required.'}
,text: {type: String, required: '{PATH} is required.'}
})
,'post'
);
module.exports.File = mongoose.model('File'
,new Schema({
id: ObjectId
,postid: {type: ObjectId, required: '{PATH} is required.', ref: 'User'}
,ext: {type: Date, required: '{PATH} is required.'}
,type: {type: String, required: '{PATH} is required.'}
,content: {type: String, required: '{PATH} is required.'}
})
,'file'
);