erikshestopal
erikshestopal
DTDrizzle Team
Created by erikshestopal on 3/29/2024 in #help
Relation join conditions
Hey - let's say I have the following SQL:
SELECT
blocks.id,
blocks.type
FROM
inspections i
INNER JOIN inspection_blocks blocks ON i.id = blocks.inspection_id AND blocks.type = 'group';
SELECT
blocks.id,
blocks.type
FROM
inspections i
INNER JOIN inspection_blocks blocks ON i.id = blocks.inspection_id AND blocks.type = 'group';
Is there any way right now to specify the join condition of the relation, e.g?
export const inspectionRelations = relations(({many}) => ({
groups: many(blocks, {
where(fields, ops) {
return ops.eq(fields.type, 'group')
}
})
}))
export const inspectionRelations = relations(({many}) => ({
groups: many(blocks, {
where(fields, ops) {
return ops.eq(fields.type, 'group')
}
})
}))
3 replies