PrismaP
Prisma2y ago
4 replies
PinkiePie

how to return an empty array instead of null

I have such a type:
type P {
  id String
  m  Int[]
}

In the database, some items doesn't have field m at all. When I query such items, m is set to
null
. How to return an empty array instead? It feel weird that Prisma disallows optional lists, so typescript type will be like that: {id: string, m: number: []} but I still have to check that the field m exists before accessing it
Was this page helpful?