-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
96 lines (86 loc) · 2.19 KB
/
db.js
File metadata and controls
96 lines (86 loc) · 2.19 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// first draft data model
const mongoose = require('mongoose');
/*
User
my site will require authentication, so users will have a username and password
users will have Year, Month, Week, and Day objects but those will be embedded
only years, months, weeks, and days with added data will be stored, and not empty years
*/
const User = new mongoose.Schema({
// username provided by authentication plugin
// password hash provided by authentication plugin
years: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Year' }],
});
/*
Year
represents a user's notes for the year
*/
const Year = new mongoose.Schema({
user: {type: mongoose.Schema.Types.ObjectId, ref:'User'},
year: {type: Number, required: true},
items: {type: [Items], required: true},
months: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Month' }]
});
/*
Month
represents a user's notes for the month
*/
const Month = new mongoose.Schema({
user: {type: mongoose.Schema.Types.ObjectId, ref:'User'},
month: {type: Number, required: true},
items: {type: [Items], required: true},
weeks: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Week' }]
});
/*
Week
represents a user's notes for the week
*/
const Week = new mongoose.Schema({
user: {type: mongoose.Schema.Types.ObjectId, ref:'User'},
week: {type: Number, required: true},
items: {type: [Items], required: true},
days: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Day' }]
});
/*
Day
represents a user's notes for the day
*/
const Day = new mongoose.Schema({
user: {type: mongoose.Schema.Types.ObjectId, ref:'User'},
day: {type: Number, required: true},
items: {type: [Items], required: true},,
});
/*
Item
represents a list of items in a user's notes
*/
const Item = new mongoose.Schema({
tasks: [Task],
events: [Event],
notes: [Note]
});
/*
Task
represents an actionable item
*/
const Task = new mongoose.Schema({
content: String,
completed: Boolean,
migrated: Boolean,
scheduled: Boolean
});
/*
Event
represents a date-related entries
*/
const Event = new mongoose.Schema({
content: String
});
/*
Notes
represents a note: can be facts, ideas, thoughts, observations
*/
const Item = new mongoose.Schema({
content: String
});
mongoose.model('User', User);