nikolasburk
prisma db seed
command which is introduced in Preview in this release. Seeding is currently supported via scripts written in TypeScript, JavaScript, Go and Shell.
The command expects a file called seed
with the respective file extension inside your main prisma
directory.
Check out the release notes for more info. Please provide feedback for the new prisma db seed
command here.
💥 Throw exceptions in findFirst
and findUnique
queries if no record is found
With the new rejectOnNotFound
option, you can now tell Prisma Client to throw an exception when findFirst
or findUnique
does not find any records.
Here's an example:
const user = await client.user.findUnique({
where: {
id: 10,
},
rejectOnNotFound: true
})
// Throws "NotFoundError: No User found" if the
// user with id = 10 does not exist.
If you omit rejectOnNotFound
, these calls continue to return undefined
.
🐘 Improved API for filtering arrays in PostgreSQL
We've added some new capabilities to your where
condition for filtering arrays in PostgreSQL:
• `has`: a value is contained within the array
• `hasEvery`: all values are contained within the array
• `hasSome`: at least one values is contained in the array
• `isEmpty`: the array is empty
Here's an example:
const admin = await prisma.user.findFirst({
where: {
id: 1,
roles: {
has: 'ADMIN'
}
}
})