Integration into our API
Prisma is a Auto-generated and type-safe query builder for Node.js & TypeScript. For every new model that is generated, Prisma will make a type of it. This way you know what data is required when making a new item in your database.
Examples
Making a new user
const newUser = await prisma.user.create({
data: {
firstname: "Jan",
lastname: "Johnson",
email: "jan.johnson@gmail.com"
}
})
Updating a user
const updatedUser = await prisma.user.create({
where: {
id: userId
},
data: {
firstname: "Joe"
}
})
Deleting a user
const deletedUser = await prisma.user.delete({
where: {
id: userId
}
})
finding a unique user
const uniqueUser = await prisma.user.findUnique({
where: {
id: userId
}
})
finding a group user who's firstname contains "John"
const uniqueUser = await prisma.user.findUnique({
where: {
firstname: {
contains: "John"
}
}
})
You can check out the Prisma documentation if you want to go more in depth.