【问题标题】:Loki js query to database returns nothingLoki js对数据库的查询不返回任何内容
【发布时间】:2016-09-12 10:31:57
【问题描述】:

我正在尝试使用 loki js 来过滤时间戳早于当前的对象:

public getExpiredElements(): any[] {
let currentDate = new Date().toISOString();
console.log(currentDate);
return this.collectionName.chain().find(this.collection).where( (obj) => {
  console.log(obj.expirationTimeStamp);
  obj.expirationTimeStamp < currentDate;
}).data();
}

虽然我得到了空桌子。我的语法正确吗?

【问题讨论】:

    标签: javascript lokijs


    【解决方案1】:

    您必须在where 方法中return 进行比较。

    this.collectionName.chain().find(this.collection).where( (obj) => { return obj.expirationTimeStamp < currentDate; })

    【讨论】:

      猜你喜欢
      • 2012-05-18
      • 2012-04-14
      • 1970-01-01
      • 2021-04-24
      • 2013-09-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多