Efficient Recursive PG SQl statement or similar

Job ID: 30846441

Budget: $10 – $30 USD

Hey all, I'm looking for a NodeJs developer who will be able to write in PG sql. They will be provided with a service to build the logic in.

Let's say we have a node with a UUID stored in the db:
{
id: 459161b1-a63d-442a-b09d-7f12a8052327
first_parent: 6a37cf1d-8821-4665-b4cb-ea4646ebcaeb,
second_parent: 7dca6156-cb18-48a1-960a-a3376477e946
}

We need a PG sql statement that will fetch both parents, their parents, and their parents' parents.

This is with the initial request. We need to be able to send a request to get additional ancestors if necessary in the most efficient way possible.

We need to do this in a way that causes the server to remain stateless. If you have any questions at all don't hesitate to reach out.