I am building an app for sharing summaries between students that behaves like a social network.
A signed user will be able to upload summaries and access a feed of uploaded summaries.
The way I have it right now:
user schema:
var userSchema = mongoose.Schema({
username : String,
password : String,
summeries: [mongoose.Schema.Types.ObjectId]
});
summaries schema:
var summerySchema = mongoose.Schema({
title : String,
username : String,
date: Date
});
I want to change it so that summerySchema is embedded to userSchema like this:
var userSchema = mongoose.Schema({
username : String,
password : String,
summeries: [summerySchema]
});
but if do so, how do I query the (let's say) 10 newest summaries from all users? (without going through the entire database? in fear of very long wait time and server overload).