Update date field with supabase's instance date

Hey! does it possible to update date field in table to be like NOW()? example:
const userId = ...
await supabase.from('table1').update({
my_updated_at: 'now()'
}).eq('user_id', userId);
const userId = ...
await supabase.from('table1').update({
my_updated_at: 'now()'
}).eq('user_id', userId);
is this valid? can't find any mention in the docs.
3 Replies
garyaustin
garyaustin4d ago
PostgreSQL Documentation
8.5. Date/Time Types
8.5. Date/Time Types # 8.5.1. Date/Time Input 8.5.2. Date/Time Output 8.5.3. Time Zones 8.5.4. Interval Input 8.5.5. Interval Output PostgreSQL supports …
Jacob
JacobOP4d ago
Nice! so it seems like now() is does supported by this update with supabase client
garyaustin
garyaustin4d ago
Yes you can use those as the column value (string) from the rest api. So you would use 'now' for the column value event though a timestamp. I prefer to use a Postgres trigger function on before update to set it to now() though. Then the user can't change it.

Did you find this page helpful?