Skip to content

Instantly share code, notes, and snippets.

@nik-neg
nik-neg / discriminate-union-zod-prisma.md
Last active January 11, 2025 19:09
Discriminate Union with Zod and Prisma

Discriminated Union Arrays in Prisma Models

Prisma currently does not support union types for fields directly in its schema. For instance, this is not possible:

model Movie {
  id        String @id @default(uuid())
  title     String
  customers (Client | User)[] // <-- Not supported in Prisma

Rough Notes about CQRS and ES

Once upon a time…

I once took notes (almost sentence by sentence with not much editing) about the architectural design concepts - Command and Query Responsibility Segregation (CQRS) and Event Sourcing (ES) - from a presentation of Greg Young and published it as a gist (with the times when a given sentence was heard).

I then found other summaries of the talk and the gist has since been growing up. See the revisions to know the changes and where they came from (aka the sources).

It seems inevitable to throw Domain Driven Design (DDD) in to the mix.