How do i insert a Enum value into a table

Basic Setup

export const userRoles = pgEnum('role', ['admin', 'maintainer']);
export const users = pgTable("userAuth", {
  id: text("id").notNull().primaryKey(),
  name: text("name"),
  email: text("email").notNull().unique(),
  emailVerified: timestamp("emailVerified"),
  image: text("image"),
  role:userRoles('role').default('maintainer').notNull()
});

 await db.insert(users).values({
        email:"a@a",
        role:userRoles.enumValues[0],
        id:"123"
    })


I get this error
 BadRequestException: ERROR: column "role" is of type role but expression is of type character varying
  Hint: You will need to rewrite or cast the expression.
  Position: 125; SQLState: 42804 
Was this page helpful?