Skip to content

Instantly share code, notes, and snippets.

@ftmoose
Created January 5, 2020 16:33
Show Gist options
  • Save ftmoose/5b6626b8e40d334695c1894d2a8c63a4 to your computer and use it in GitHub Desktop.
Save ftmoose/5b6626b8e40d334695c1894d2a8c63a4 to your computer and use it in GitHub Desktop.
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