Last active
October 6, 2021 23:02
-
-
Save muratgozel/d764bab633bd1a77d8a499c91af2690e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// filtering something by its lifetime with slonik | |
const filterByLifetimeQuery = sql` | |
select id | |
from eventlog | |
where | |
code=${code} and | |
payload=${sql.json(payload)} and | |
created_at + interval '1 second' * ${parseInt(ctx.threshold)} > now() | |
` | |
// remove properties from jsonb field | |
const updateFieldQuery = sql` | |
update methods | |
set | |
credentials = credentials - '{password,salt}'::text[], | |
status='ACTIVE' | |
where id=${method.id} | |
` | |
// get timestamp for a future date | |
const tokenLife = '3 hours' | |
const willExpireAtQuery = sql` | |
SELECT to_timestamp(${Date.now()/1000}) + ${tokenLife}::interval as date; | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment