matthewfranglen / postgres-elasticsearch-fdw

Postgres to Elastic Search Foreign Data Wrapper
MIT License
111 stars 32 forks source link

WIP: Add refresh parameter to insert #15

Closed aileo closed 3 years ago

aileo commented 3 years ago

related to #13

aileo commented 3 years ago

At this point, using refresh 'wait_for' and CTE allow to get the full document back with a join:

using schema from tests

WITH
inserted AS (
  INSERT INTO articles_es_wait_for (id, title, body)
  VALUES (2, 'test title', 'test body') RETURNING id
)
SELECT es.id, es.title, es.body FROM inserted
LEFT JOIN articles_es_wait_for as es ON es.id = inserted.id;

-- > 2 | test title | test body

Should the full return be implemented as this workaround if pretty light and save a call?

matthewfranglen commented 3 years ago

It doesn't really save a call? You still have to query the fdw to get the data.

This is where invoking the read method with the ids would be appropriate. I'm happy to take this on if you don't want to handle that.

aileo commented 3 years ago

It doesn't really save a call? You still have to query the fdw to get the data.

Sorry, I don't know how I could think it save something...

This is where invoking the read method with the ids would be appropriate. I'm happy to take this on if you don't want to handle that.

I will let you go on then, I have no idea where to start :)

matthewfranglen commented 3 years ago

I should be able to work on this a bit tonight.

matthewfranglen commented 3 years ago

I've ended up smashing a few unrelated changes in here too.