mol*_*rat 5 pagination mongoose mongodb node.js mongoose-plugins
我想我的排序Group由-模型name的departure_country与猫鼬,PAGINATE和的NodeJS.
我的小组 - 架构:
var GroupSchema = new Schema({
name: String,
flight_date: Date,
....
departure_country: {type: Schema.ObjectId, ref: 'Country'},
....
});
Run Code Online (Sandbox Code Playgroud)
在乡村架构:
var CountrySchema = new Schema({
name: String,
code: String,
});
Run Code Online (Sandbox Code Playgroud)
使用国家的sortBymongoose-paginate排序 - _ids我不知道如何告诉它按照排序name.
将国家/地区代码设置为 Country-Schema 的 _id 怎么样?
然后departure_country: {type: String, ref: 'Country'}
这实际上可能是一个更好的设计。Country-Schemas _id 会很小,并且国家/地区代码不应发生冲突。另外,GroupSchema您将使用更少的空间来存储“外键” departure_country。
那么您就可以进行排序departure_country,并且该排序有可能对国家/地区名称也有效。
| 归档时间: |
|
| 查看次数: |
690 次 |
| 最近记录: |