meilisync
meilisync copied to clipboard
Join multiple sql tables
Please tell me how to get source parameters inside the plugin? I want to supplement with data from other tables by making SQL queries inside pre_event.
Try writing a view? eg for postgresql
CREATE VIEW meilisearch_view AS
SELECT
users.id_key,
other.foo,
FROM
users
LEFT JOIN
other ON users.id_key = other.user_id;
If I use views in mysql, database changes are not tracked.
A view will not be output by wal2json (in the case of postgresql) and probaly neither will mysql.
Using a materialized view works fine since the data is physically stored in a table. Just keep in mind you have to refresh the materialized view after updating any of the source tables
CREATE MATERIALIZED VIEW meilisearch_view AS
SELECT
users.id_key,
other.foo,
FROM
users
LEFT JOIN
other ON users.id_key = other.user_id;