您好我的项目详情如下:
{
_id: "55efee0503218232d97d40a1"
restaurant: "55d86ccea5fce89408ab4f73"
name: "Sutffing Paratha"
itemCode: "sky121"
costPrice: 62.4
sellingPrice: 80
price: 80
category: "Roti"
type: "Veg"
cuisine: "Indian"
head: ""
hotnessMeter: "2"
featuredItem: ""
serialNo: 121
created: "2015-09-09T08:29:57.235Z"
__v: 0
}
我想通过排序' serialNo'来获取所有项目组。 我已经完成了以下查询,但我无法获得基于serialNo的记录排序。
Items.aggregate([ {
'$sort': {
'serialNo': -1
}
}, {
'$match': {
'restaurant': restaurantId
}
}, {
'$group': {
_id: {
cuisine: '$cuisine'
},
id: {
'$push': '$$ROOT'
}
}
}]).exec(function(err, items) {
// certain manipulation on data to send response as expected.
});
请你在这里建议我做错了什么。