akito
04/17/2022, 12:32 AM{"timestamp":0,"accesses":0}
but I would like to set that timestamp to the current UNIX timestamp when a row is created through a triggerNeedle
04/17/2022, 12:32 AM/title
command!
We have solved your problem?
Click the button below to archive it.tourdownunder
04/17/2022, 3:30 AMsql
SELECT json_build_object('timestamp', EXTRACT(EPOCH FROM now()), 'acesses', 0)
Needle
04/17/2022, 3:30 AMakito
04/17/2022, 6:02 AMakito
04/17/2022, 7:13 AMSELECT json_build_object(
'timestamp', ROUND(EXTRACT(EPOCH FROM now())),
'accesses', 0
) AS built_bucket_data;
INSERT INTO public.user_data (user_id, bucket_data)
VALUES ('6cf9c0d5-eeee-eeee-eeee-d09baab689df', built_bucket_data);
I put this into the SQL editor for testing and I think this should work, I'm getting column "built_bucket_data" does not exist
though. I'm not familiar with postgresql at all - I'm pretty sure the INSERT
call has the right format, so maybe it's SELECT which is being weird.akito
04/17/2022, 7:13 AMakito
04/17/2022, 7:54 AMWITH constants (built_bucket_data) as (SELECT json_build_object(
'timestamp', ROUND(EXTRACT(EPOCH FROM now())),
'accesses', 0
))
INSERT INTO public.user_data (user_id, bucket_data)
VALUES ('6cf9c0d5-eeee-eeee-eeee-d09baab689df', (SELECT built_bucket_data FROM constants));