Upsert question
I'm retrieving orders every 30 minutes that may be the same or some may be updated so I want the row to just update with the new information but I don't know how to do that, in the docs it only shows updating all the rows with a set value. Is there a way to update each row with the new data? I've attached an image to give an understanding of what im wanting
4 Replies
Looks like formattedOrders is an array?
According to the postgress docs: https://www.postgresql.org/docs/current/sql-insert.html
PostgreSQL Documentation
INSERT
INSERT INSERT — create new rows in a table Synopsis [ WITH [ RECURSIVE ] with_query [, ...] ] INSERT …
The SET and WHERE clauses in ON CONFLICT DO UPDATE have access to the existing row using the table's name (or an alias), and to the row proposed for insertion using the special excluded table.So you have access the old value in the row with the table name, and to to the row being inserted with the
excluded
keyword.
Take a look at this link for an example: https://discord.com/channels/1043890932593987624/1149847252060352522/1150934123268018246thats perfect thankyou mate!