【问题标题】:moongose db or kwyword in where clasuemongoose db 或 where 子句中的关键字
【发布时间】:2014-02-13 17:03:13
【问题描述】:

如何像我们在 sql 中那样在 mongoose where 子句中放置或设置条件 select * from tablename where col='test' or col2 ='test1'

this.find(标准) .sort({'createdAt': -1}) // 按日期排序 .limit(options.perPage) .skip(options.perPage * options.pagenum) .where($or: [{'category' : options.category},{'title' :{$regex : options.search}}]) .exec(cb);

【问题讨论】:

  • 你提出问题后做了什么?请正确格式化并尝试很好地解释您的问题

标签: mongodb angularjs mongoose


【解决方案1】:

你可以这样做;

Model.find({col: "test", col2="test1"}, function(err, result) {
    if (err) {
    // error
    } else {
    // result
    }
});

【讨论】:

    猜你喜欢
    • 2016-03-03
    • 2016-01-29
    • 2015-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多