I have User
schema:
{
name: String
...
}
I also have Contract
schema:
{
user: { type: ObjectId, ref: 'User' }
...
}
Then i want to sort contracts like this:
ContractModel.find().sort({ "user.name": -1 }).exec(...);
Is it possible somehow without getting all data? Or what are alternative solutions? Thanks