码迷,mamicode.com
首页 > 数据库 > 详细

mongodb 降序

时间:2018-02-02 14:26:58      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:exec   com   await   ted   gpo   mongod   use   nbsp   div   

降序排序

db.mycol.find({},{"title":1,_id:0}).sort({"title":-1})// 1用于升序排列,而-1用于降序。

示例代码:

    var user = await Kitten.find({
        types: "散文随笔",
        _id: ctx.query.id
    }).sort({
        "createAt": -1
    }).exec();
    var comment = await Comment.find({
        Postedid: ctx.query.id
    })

 

mongodb 降序

标签:exec   com   await   ted   gpo   mongod   use   nbsp   div   

原文地址:https://www.cnblogs.com/yu-hailong/p/8404364.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!