【发布时间】:2020-12-18 19:08:19
【问题描述】:
我有猫鼬模型:
const mongoose = require('mongoose')
const { Schema } = mongoose
const schema = new Schema({
Name: { type: String },
Category: { type: String },
Price: { type: Number }
})
module.exports = mongoose.model('Product', schema)
我必须按类别字段排序。排序顺序是
['Clothes', 'Accessories', 'Footwears']
我是怎么做到的?
【问题讨论】:
-
我的意思是我该怎么做?
-
这能回答你的问题吗? How to sort in mongoose?