Perform update operations using prisma client

Share this video with your friends

Send Tweet
Published 2 years ago
Updated a year ago

In this lesson you will learn how to perform the update operations on postgres table entries using prisma client.

Dimitri Ivashchuk: [0:00] Now we want to update the user with some particular id. In this case, we are fetching the user with id 9, and the name is alex. We want to make it capital letter A. Let's try to do that. Comment this one for now.

[0:18] To do it with Prisma is quite simple. We do await prisma.users.update and then inside here, we need to pass where, where we specify concrete data rule that we want to modify. In this case, it would be the id 9 and as a second parameter, we need to pass the data.

[0:46] The name would be Alex. We save that, comment it out for now, and log the user. You see that the name is Alex now so our small query has worked correctly. Without commenting it out, we can change it straight ahead.

[1:12] You see that it changes to New user and basically, that would be it for doing the small updates for Prisma.