0

我正在尝试使用 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();
}

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

4

1 回答 1

0

您必须returnwhere方法中进行比较。

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

于 2017-09-07T23:27:36.540 回答