Surgex.DataPipe.TableSync (Surgex v5.0.0) View Source

Extracts and transforms data from one PostgreSQL table into another.

Usage

Refer to Surgex.DataPipe for a complete data pipe example.

Link to this section Summary

Functions

Synchronizes the given repository's table with data fetched using a specified query.

Link to this section Functions

Link to this function

call(repo, source, target, opts \\ [])

View Source

Synchronizes the given repository's table with data fetched using a specified query.

The synchronization is done via a single SQL query by utilizing the WITH statement. It first executes INSERT .. ON CONFLICT (called "upserting") to insert and update new rows, followed by DELETE .. WHERE that removes old entries that didn't appear in the input query.

Returns a tuple with a number of upserts (inserts + updates) and a number of deletions.