Created
January 5, 2020 16:33
-
-
Save ftmoose/5b6626b8e40d334695c1894d2a8c63a4 to your computer and use it in GitHub Desktop.
This file contains 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
const postSchema = new Schema({ | |
type: { type: String, enum: ['blurb', 'image', 'video'] }, | |
blurb: { type: String, required: true }, | |
media: String, | |
user: { | |
id: { type: ObjectId, ref: 'user', required: true }, | |
username: String, | |
picture: String | |
}, | |
created: { type: Date } | |
}); | |
postSchema.index({ "user.id": 1, created: -1 }); | |
postSchema.index({ _id: 1, "user.id": 1 }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment