jon.m
08/31/2021, 3:30 AMjason-lynx
08/31/2021, 4:25 AMWITH insert_thread AS (
INSERT INTO threads
VALUES (...)
RETURNING thread_id
),
insert_participants AS (
INSERT INTO participants (..., thread_id)
VALUES (..., (SELECT thread_id FROM insert_thread))
),
insert_message AS (
INSERT INTO messages (..., thread_id)
VALUES (..., (SELECT thread_id FROM insert_thread))
)
...
jason-lynx
08/31/2021, 4:26 AMRETURNING
part is probably what you're looking for, where you can pass the newly created ids into another queryjason-lynx
08/31/2021, 4:27 AMjon.m
08/31/2021, 2:06 PMjon.m
09/01/2021, 3:11 PM