我通过填充这样的广告来获得用户架构广告:
let user;
try {
user = await User.findOne({ _id: id }).populate('ads').sort([ [ 'date', -1 ] ]);
} catch (e) {
console.log('Could not post user : ' + e);
return next(e);
}
res.json({
ads: user.ads
});
但是排序不起作用。
如何按日期将广告排序?