-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodels.js
More file actions
61 lines (57 loc) · 1.02 KB
/
models.js
File metadata and controls
61 lines (57 loc) · 1.02 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
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const dreamSchema = new Schema({
title:{
type: String,
required: true,
},
content: {
type: String,
required: true,
},
userId: {
type: String,
required: true,
},
images: [{ type: Schema.Types.ObjectId, ref: 'Image' }]
}, {timestamps: true});
const imageSchema = new Schema({
url: {
type: String,
required: true,
},
keyword: {
type: String,
required: true,
},
lastViewedIndex: {
type: Number,
required: true,
},
}, {timestamps: true});
const articleSchema = new Schema({
headline:{
type: String,
required: true,
},
webUrl:{
type: String,
required: true
},
snippet:{
type: String,
required: true
},
image:{
type: String,
required: true
}
})
const Article = mongoose.model('Article', articleSchema);
const Dream = mongoose.model('Dream', dreamSchema);
const Image = mongoose.model('Image', imageSchema);
module.exports = {
Article,
Dream,
Image,
};