Created
February 12, 2020 16:14
-
-
Save eoanodea/0c8c54510e79cfe24cb36e9293741c97 to your computer and use it in GitHub Desktop.
Post and Media Mongoose Schema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Post Schema | |
const PostSchema = new mongoose.Schema({ | |
text: { | |
type: String, | |
}, | |
photo: { | |
data: Buffer, | |
contentType: String, | |
}, | |
orientation: Number, | |
likes: [{type: mongoose.Schema.ObjectId, ref: 'User'}], | |
views: {type: Number, default: 0}, | |
comments: [{ | |
text: String, | |
created: { type: Date, default: Date.now }, | |
postedBy: { type: mongoose.Schema.ObjectId, ref: 'User'} | |
}], | |
postedBy: {type: mongoose.Schema.ObjectId, ref: 'User'}, | |
created: { | |
type: Date, | |
default: Date.now | |
}, | |
type: { | |
type: String | |
} | |
}) | |
//Media Schema | |
const MediaSchema = new mongoose.Schema({ | |
text: { | |
type: String, | |
}, | |
likes: [{type: mongoose.Schema.ObjectId, ref: 'User'}], | |
views: {type: Number, default: 0}, | |
comments: [{ | |
text: String, | |
created: { type: Date, default: Date.now }, | |
postedBy: { type: mongoose.Schema.ObjectId, ref: 'User'} | |
}], | |
postedBy: {type: mongoose.Schema.ObjectId, ref: 'User'}, | |
created: { | |
type: Date, | |
default: Date.now | |
}, | |
type: { | |
type: String | |
}, | |
updated: { | |
type: Date | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment