Drizzle ORM select return string that isn't a column

153 Views Asked by At

I have a SQL query like this:

SELECT *
FROM (
   SELECT 'car' AS type, model FROM car
      UNION
   SELECT 'truck' AS type, model FROM trucks
) vehicles;

I want to replicate the 'car' as type part in Drizzle so I can distinguish the data being returned without adding a column "type" to both tables and having repetitive data.

Tried something like this, but it says a string cannot be assigned to type.

const items = db
      .select({
        type: `car`,
        id: cars.id,
      })

Is there a way to do this currently?

0

There are 0 best solutions below