mongoose-paginate sorting by referenced document mongoose-paginate sorting by referenced document mongoose mongoose

mongoose-paginate sorting by referenced document


how about making the country code the _id of Country-Schema?

then departure_country: {type: String, ref: 'Country'}

That might actually be a better design. Country-Schemas _id would be small, and country codes shouldn't have collisions. Also in GroupSchema you'd use less space to store the "foreign key" departure_country.

then you'd be able to sort by departure_country and there's a chance the sort would also be valid for country name.