【问题标题】:Sails.js waterline destroy "lower or equal" criteriaSails.js 水线破坏“低于或等于”标准
【发布时间】:2015-11-12 03:47:23
【问题描述】:

我正在尝试使用低于请求中的 destroy 方法,但我无法使其工作。

虽然,find 方法返回一些具有完全相同参数的内容。

Cars.find({userId: params.userId, accessDate: { '<=': new Date() }}, function (err, found) {
    console.log(found); //Returns an array with multiple entries.
}); 

Cars.destroy({userId: params.userId, accessDate: { '<=': new Date() }}); //Does nothing, the entries are not destroyed.

这是我的数据库中第一个请求返回的内容:

[ { userId: '563c1c37be1ed48e7f8c6ada',
    accessDate: '2015-11-07T21:36:13.169Z',
    id: '563e60bd19667c52bd831182' },
  { userId: '563c1c37be1ed48e7f8c6ada',
    accessDate: '2015-11-10T05:04:01.850Z',
    id: '56416cb140112987ce6ec049' },
  { userId: '563c1c37be1ed48e7f8c6ada',
    accessDate: '2015-11-12T03:59:36.519Z',
    id: '5644009851503b42e589ecf1' } ]

我是不是哪里错了?我该怎么办?

谢谢。

【问题讨论】:

    标签: javascript node.js sails.js waterline sails-mongo


    【解决方案1】:
        Cars.find({userId: params.userId, accessDate: { '<=': new Date() }})
        .exec(function (err, found) {
    
        });
    
        Cars.destroy({userId: params.userId, accessDate: { '<=': new Date() }})
        .exec(function (err) {
    
        });
    

    希望有帮助

    【讨论】:

    • 嗯...这很奇怪!我认为不需要回调。但是,是的,这适用于回调!谢谢
    猜你喜欢
    • 2014-08-11
    • 1970-01-01
    • 2014-12-14
    • 2017-05-18
    • 2020-05-05
    • 1970-01-01
    • 1970-01-01
    • 2018-09-02
    • 2015-01-03
    相关资源
    最近更新 更多