Creation of FTS column which combines data from two different tables inside VIEW
I want to create fts column for the full text search combining the data from two different tables which have relationship between:
If I query
But if I query
This is because I create a view with
How can I go around it?
create table countries {
id: uuid();
name: string;
}create table cities {
id: uuid();
name: string;
counry_id: uuid references countries(id)
}
CREATE VIEW cities_fts
SELECT
cities.id as city_id,
cities.country_id as county_id, to_tsvector('english', concat_ws(' ', cities.name, country.name )) AS fts
FROM countries, cities
WHERE (cities.country_id = countries.id);
If I query
.from('custom_view').select(*, counties(*)) I will get a response with country object included.But if I query
.from('custom_view').select(*, cities(*)) I'll get an error about no relationship between custom_view view and citiesThis is because I create a view with
cities.id which is just a id and not a foreign key and cities.county_id which is a foreign key, right? How can I go around it?