Goldstair
Goldstair
DTDrizzle Team
Created by Goldstair on 6/21/2023 in #help
Inserting into columns of type Enum
Hi, any code written here was done in TypeScript and the database I’m connecting to is AWS Aurora PostgreSQL. (I’m on mobile, sorry about the format) I’ve defined an enum as follows: const CardType = pgEnum(‘CardType’, [‘VOCAB’, ‘GRAMMAR’]); I’m using it in a table as follows: const Card = pgTable(‘Card’, { type: CardType(‘type’).notNull(), // other fields }); When trying to insert into the Card table with: db.insert(Card).values({type: ‘VOCAB’, /other fields/}) I keep getting the error “column ‘type’ is of type cardtype but expression is of type character varying”. I’ve tried declaring the inserted object separately with type InferModel<typeof Card, “insert”>, but the error persists. Sorry if this is a very simple question. I’m quite new to using Drizzle and would appreciate any help I can get on this matter. Thank you!
10 replies