Using `$dynamic()` to enhance where clause

I have a function like:

export const applyFilter = (qb: SQLiteSelect, paging: Paging, filter: string | undefined) => { .. }

which adds limit and offset and also where using qb.where(..).

This works great, but now I have the use case the qb received already contains a where clause.
But the qb.where(..) overwrites it unfortunately.

Is there a way to merge them instead, if the qb already has a where?
Was this page helpful?