Skip to content

whereHas / whereDoesntHave

Find records that have at least one related record matching a condition:

// Users who have at least one published post
const authors = await pulsabase.from(User)
.whereHas('posts', (q) => q.where('status', 'published'))
.find();

Find records with no matching related records:

// Users who never placed an order
const inactive = await pulsabase.from(User)
.whereDoesntHave('orders')
.find();