Skip to content

Lucid - JOIN with inline table #4948

Answered by thedomeffm
thedomeffm asked this question in Help
Discussion options

You must be logged in to vote

Ok, after some help from Copilot and Gemini I got it working:

Product.query()
    .joinRaw(
        'JOIN unnest(?::text[]) AS terms(term) ON "product"."name" % terms.term',
        [names.map((name) => name.trim())],
    )
    .orderBy('name', 'asc');

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@thedomeffm
Comment options

Answer selected by thedomeffm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant