Closed YannisMarios closed 6 years ago
Hi, I have a question
I have defined a static method like this:
accessTokens.defineStatic('removeExpired', async function() { let expired = await this.filter(token => token('expires_on').lt(new Date())); if(expired.length) { expired.forEach(token => async () => { await this.delete(token.id) }) } });
expired is an array of objects and I would like to delete them without having to loop over them by doing something like:
await this.filter(token => token('expires_on').lt(new Date())).delete()
is this possible? I tried this above and I get error: ThinkyError: Value for [id] must be defined.
in ReQL it is possible to do: r.db("auth_db").table("accessTokens").filter(token => token('expires_on').lt(new Date())).delete()
Does await this.filter(token => token('expires_on').lt(new Date())).delete().execute() do the trick?
await this.filter(token => token('expires_on').lt(new Date())).delete().execute()
@cur3n4 It works!!! Thank you!!
I can't believe I missed this!
@YannisMarios My pleasure
Hi, I have a question
I have defined a static method like this:
expired is an array of objects and I would like to delete them without having to loop over them by doing something like:
await this.filter(token => token('expires_on').lt(new Date())).delete()
is this possible? I tried this above and I get error: ThinkyError: Value for [id] must be defined.
in ReQL it is possible to do: r.db("auth_db").table("accessTokens").filter(token => token('expires_on').lt(new Date())).delete()