【问题标题】:Sort Mongoose data对 Mongoose 数据进行排序
【发布时间】:2018-01-15 00:40:44
【问题描述】:

我正在对我的猫鼬数据进行排序。目前我在下面所做的工作完美:

 Rentals.find({}).sort({featured: -1})

我现在正在尝试添加一种方法来不显示“保留”的租金。

我一直在尝试,但它不起作用:

if (!Rentals.reserved) { 
Rentals.find({}).sort({featured: -1})

这样做的正确方法是什么?

谢谢!

【问题讨论】:

    标签: node.js mongodb sorting mongoose database


    【解决方案1】:

    我假设reserved 是一个布尔值,那么就这样做

    Rentals.find({ reserved: false }).sort({featured: -1})
    

    【讨论】:

    • 你摇滚@Mikey
    猜你喜欢
    • 2020-01-03
    • 1970-01-01
    • 2014-12-24
    • 2016-09-15
    • 1970-01-01
    • 2016-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多