0

I am trying to use loki js in order to filter the objects whose timestamps are older than current:

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();
}

I get empty table though. Is my syntax correct?

Jerzy Gruszka
  • 1,629
  • 4
  • 15
  • 20

1 Answers1

0

You must return your comparison in the where method.

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

ihsanberahim
  • 1,051
  • 12
  • 14