How to narrow type in select from enum?

During select I need to narrow enum type from multiple choices to one choice eg just 'product'

schema
export const typAsortymentuEnum = pgEnum('typ_asortymentu', ['produkt', 'usluga']);
export const asortyment = pgTable('asortyment', {
    id: serial('id').primaryKey().notNull(),
    typ: typAsortymentuEnum('typ').notNull(),
   
})


query
    const produkt = alias(asortyment, "produkt")
 const results = await db
        .select({
            id: produkt.id,
            typ: produkt.typ,
        })
        .from(produkt)
        .where(eq(produkt.typ, 'produkt'))
        .execute()

result typ value is typed as typ: "produkt" | "usluga"; and I need to narrow it to just product

I would be glad for any tip how to accomplish this. Thanks!
Was this page helpful?