-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.js
62 lines (55 loc) · 1.34 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
52
53
54
55
56
57
58
59
60
61
62
'use strict'
const mongoose = require('mongoose')
const ProfileSchema = new mongoose.Schema({
id: String,
name: String,
description: String,
mbti: String,
enneagram: String,
variant: String,
tritype: Number,
socionics: String,
sloan: String,
psyche: String,
image: String
})
const Profile = mongoose.model('Profile', ProfileSchema)
module.exports.Profile = Profile
const CommentSchema = new mongoose.Schema(
{
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Profile',
required: true
},
personalities: {
type: Map,
of: String,
default: {}
},
text: String,
title: String
},
{ timestamps: true }
)
const Comment = mongoose.model('Comment', CommentSchema)
module.exports.Comment = Comment
// add schema for CommentLike, it should have a user field that is a reference to the Profile model
// plus it should have a comment field that is a reference to the Comment model
const CommentLikeSchema = new mongoose.Schema(
{
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Profile',
required: true
},
comment: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Comment',
required: true
}
},
{ timestamps: true }
)
const CommentLike = mongoose.model('CommentLike', CommentLikeSchema)
module.exports.CommentLike = CommentLike