Option filter parameters

Vvapor5/24/2023
Hi! Love using drizzle so far! Had a quick question (not a bug):

  const res = await ctx.database
    .select()
    .from(worker)
    .where(
      and(
        eq(worker.locationUid, input.location),
        isNull(worker.deletedAt),
        ilike(worker.name, "%{input.name}%")
      )
    )


If I have a query like this, and input.name might be null (in which case I want to skip filtering by this), is there a short-hand for enabling that behavior? Right now I'm putting filters into an array like:

[..., input.name && ilike(worker.name, "%{input.name}%) : null].filter(v => v)


which is fine, just wondering if this is a good approach. thanks!
ASAndrii Sherman5/24/2023
Hi!
ASAndrii Sherman5/24/2023
here you go
ASAndrii Sherman5/24/2023
just small example I did for another thread
ASAndrii Sherman5/24/2023
but should work well for you
ASAndrii Sherman5/24/2023
we will also add this case to docs
ASAndrii Sherman5/24/2023
will work on examples section for different cases like this one
ASAndrii Sherman5/24/2023
all you need from this examples is that filter statements can be grouped in array
ASAndrii Sherman5/24/2023
and then used like this
.where(and(...filters))
Vvapor5/24/2023
great thanks, looks good