找不到记录时如何获取带有 Prisma2 错误的空数组
How to get an empty array with Prisma2 error when no records found
当数据库中没有记录时,Photon (Prisma2) 会抛出错误,而不是像 Prisma 那样返回空数组。处理这个问题的最佳方法是什么,在没有找到记录时得到一个空数组?我不希望我所有的 Photon 查询都被 try 和 catch 语句包围。
例如:
photon.context.photon.users.findOne({ where: { email } })
报错:
Error in connector: Record does not exist.
当数据库中没有记录时,Photon (Prisma2) 会抛出错误,而不是像 Prisma 那样返回空数组。处理这个问题的最佳方法是什么,在没有找到记录时得到一个空数组?我不希望我所有的 Photon 查询都被 try 和 catch 语句包围。
例如:
photon.context.photon.users.findOne({ where: { email } })
报错:
Error in connector: Record does not exist.