Open DrTtnk opened 1 week ago
It would be a nice to have for strict type checking
import * as DP from "drizzle-orm/pg-core"; export const Participant = DP.pgTable( "participants", { id: DP.uuid("id").primaryKey(), name: DP.varchar("name", { length: 500 }).notNull(), surname: DP.varchar("surname", { length: 500 }).notNull(), email: DP.varchar("email", { length: 100 }).$type<DT.Email>().unique("email_unique").notNull(), bio: DP.text("bio").notNull(), }, tb => ({ uniq: DP.primaryKey({ columns: [tb.id], name: "no_homonymies" }) }), ); export type ParticipantInsert = DO.InferInsertModel<typeof Participant>; export type Constraints = (typeof Participant)["_"]["config"]["contraints"]; // ^ ['email_unique', 'no_homonymies', '<the generated one for id>']
Such that in case of insert/update I can discriminate between different constraints and have TS validating my logic
Would this be possible and, hopefully, easy to implement?
Describe what you want
It would be a nice to have for strict type checking
Such that in case of insert/update I can discriminate between different constraints and have TS validating my logic
Would this be possible and, hopefully, easy to implement?