Search Relation table
Hi, I'm building a searching feature, and one of the columns "invoice" has a relation to a different table "customer".
I'd like to know how can I access the name of the customer within the invoice. Here's the code:
import { getXataClient } from "@/app/xata";
const xata = getXataClient();
export const searchInvoice = async (phrase: string) => {
const results = await xata.db.invoice.search(phrase, {
target: ["customer.name", "products", "address"],
fuzziness: 1,
prefix: "phrase",
});
return results;
};
Thanks in advance1 Reply
Hi, in Search it is not possible to access linked columns or apply filters on them. Within each table in the Search store, columns of link type contain only the id of the linked record, they don't link to the content itself. You would need to keep all the columns you're searching for within the same table. This is a known limitation that we're planning to work on in the future (record denormalization).