Prisma in Next.js - My Fav Way to Work with Databases (CRUD, Dev/Prod Workflow, Relations, Indexes)
👉 Check out Prisma: www.prisma.io/?via=bytegrad (paid sponsorship & I get commission from your purchases)
Disclaimer: this is a sponsored video (paid). It's your responsibility to evaluate safety, accuracy and other relevant parts of the reviewed product.
👉 NEW React & Next.js Course: bytegrad.com/courses/professi...
Hi, I'm Wesley. I'm a brand ambassador for Kinde (paid sponsorship).
👉 Check out Kinde for auth and more bit.ly/3QOe1Bh
👉 NEW React & Next.js Course: bytegrad.com/courses/professi...
👉 Professional JavaScript Course: bytegrad.com/courses/professi...
👉 Professional CSS Course: bytegrad.com/courses/professi...
👉 Web development roadmap 2024 & 2025: email.bytegrad.com
👉 Email newsletter (BIG update soon): email.bytegrad.com
👉 Discord: all my courses have a private Discord
⏱️ Timestamps:
00:00 Intro
01:07 Next.js architecture
02:02 Example app overview
03:15 Setup Prisma
06:09 Schema fundamentals
07:36 Prisma extension + defaultFormatter
08:34 Schema fundamentals (continued)
10:09 Create database
12:38 View database content (Prisma Studio)
14:13 GET data on page (findMany)
16:50 Prisma Client instantiation
18:29 GET data on page (findUnique)
22:18 Changing schema (Slug) - npx prisma db push
25:38 @unique
27:42 @map
28:04 @index
28:53 Filtering (where)
29:55 Ordering
30:18 Select
31:00 Pagination
32:29 Count
33:42 Writing data (POST / PUT / DELETE)
42:03 Relations (one-to-many)
43:54 Many-to-many
44:27 One-to-one
46:50 include & connect (relations queries)
49:12 Seeding database
51:10 Prisma types
53:13 Seeding database (continued)
55:50 Error handling
57:35 Caching in Next.js
59:59 Prisma Accelerate caching
1:00:34 Going to production
1:04:32 Migrations
1:06:15 npx prisma migrate
1:08:18 postinstall (prisma generate)
1:08:42 Push to Vercel
1:10:19 Serverless vs Edge
1:10:59 Middleware (edge)
1:13:07 Prisma Pulse
#webdevelopment #reactjs #nextjs
Пікірлер: 89
Man is the best teacher who doesn't give me anxiety while learning
10 mins in and it is already solving me a lot of doubts about Next js omg, thank you
THIS IS THE BEST EXPLAINED VIDEO FOR PRISMA !!!!! Thank you so much for dwelling into even the minor details so that people who dont even have a clue bout what it is can easily understand it.
Bro read my mind, yesterday I was thinking about when you will make a video on Prisma..and here it is 🙏
@enn_nj
Ай бұрын
😂same with me bro..i love you so much bro, you read our mind😂🙏🏻🙏🏻🙏🏻 that's what i need..thankyou so muchh💐💐💐♥️
I'm only half way through and I've already learnt so many new things, thank you!!! Brilliant video ❤
Incredible video!
@ByteGrad
Ай бұрын
Any time!
Was planning to get back to full-stack dev using prisma with Nextjs to create some side projects and this video comes in. Definitely will help a ton, thanks! 😁
The timing of this video is divinely. Love you bro.
Nice one, will definitely check it out when I have time, I'm excited already, but we'll also love you to do a NodeJs Express course
dankjewel voor de video kerel
Awesome, keep up the great work 💖
very very very awesome. you sir is a natural born teacher. respect
I love you man. Thanks! Great content :)
Thanks for this amazing content!
It is a very informative lesson! Thank you!
Man,I really thought I can use Prisma. Thanks a lot for this🔥🔥🔥
Great content! thanks for sharing
THANK YOU! You're AWESOME!
@ByteGrad can you next do tRPC with Next.js App Router? Also, you are the best teacher of the t3 stack out there. The way you teach us in such depth is awesome!
Could you please make a tutorial specifically on how to use Prisma from development, and testing to production with some concrete examples?
Awesome Video, Please Do a video On Dashboard Tutorial with Next Auth, SeverActions, Prisma and Mongodb
Wow great video Byte. Really well explained. The only question I have is what if I have 2 different database to access. How are you going to make your clients? Is it going to be in the same db.ts?
Hey bytegrad I really enjoy your content and recently have been following along in some of your content, and I like kinde authentication. I’m building a full stack application for a childcare company and it would be a good video idea to show admin authorization and interacting with the kinde API to manage users from a secured back end admin panel this would help me out tremendously! I really enjoy the content though keep up the good work!
Great video. You were right, caching deserves its own video. Could you please upload a video that handles caching?
@ByteGrad
Ай бұрын
Yes, coming soon!
@armaandhanji2112
Ай бұрын
Looking forward to the caching video alot too!
Useful stuff
When creating post, why client component was not used
as always greate video ❤❤
@enn_nj
Ай бұрын
The best video from the best teacher 🙏🏻🙏🏻🙏🏻🙏🏻i really like this Chanel.
One warning about prisma that most developers (including myself) overlook, it does not support optimistic rowlocking API calls. You will have to use Raw SQL for that and it gets very messy / hard to do when accounting for race conditions in production.
Thank you
NICE!
Sir make a full video of supabase and next js as backend
Helpful video! Can we get a github repo?
I have a large database relational database with 30+ tables. Does Prisma still have issues doing relationship joins without having to scan the whole table - I have been looking into drizzle Just because we do a lot of relational joins. Just at the very small community and not as much documentation / examples. Love love love all your videos !!!!!! Keep it up king
thank you
Please also consider the fact that there are use cases where we have a standalone node/nestjs backend with an ORM, a nextjs app maybe one of the clients using the APIs. so no point in implementing the ORM in the nextjs too. what would be a better solution here? RQ?
i am about to start out, should i go with Prisma or drizzle?
sir your video is very helpfull to me. i have compleated the above video. but i have issue with the update post which i have tried in same way as server acton use for create post. how to pass the id in action={updatePost}. how to pass the id? please help
Hey, everybody! Can someone explain why after the application build, the updated data in the database is not updated on the client? The component is server-side
Hey man - as an aside to this video being related to prisma - I'm looking at a new hosting provider, and they are only offering sql databases for the backend - would you recommend using regular sql databases with nextjs and react? Projects would be small to medium in terms of requests and users. If you could give us your advice on that, it would be much appreciated!
What would you suggest if the revalidatePath is not refreshing the input and content boxes after submitting a post? The new post appears but the data is not cleared from input nor content.
i m new on nextJs so help me to use delete and update operation in the frontend ui code.How to execute the created function in the UI form?help me plzzz
i can't find data type cuid() in the description postgre, it's have only uuid()
Does anyone have a problem with form fields not reset after submission?
Could you please make a project on credentials and social oauth using Auth.js, Supabase. We can also use resend for sign up confirmation and forgot password.
can you make a video to show recommended way of doing filtering, sorting, search with nextjs and prisma??
@alaskandonut
Ай бұрын
The prisma documentation is pretty easy to read on search and filter. It’s really not bad at all.
When you need to get data from db to a client component would you say the best way is by fetching the data in a parent server component and then passing it down to the client as props?
@ByteGrad
Ай бұрын
That would be pretty typical yes
I am stuck on trying to figure out how sqlite runs on apple silicon. home-brew doesn't seem to work edit: It seems to come preinstalled on macOS. How weird is that!
hey @bytegrad, this workflow & advance tutorial is available on your course?
@ByteGrad
Ай бұрын
We also use Prisma in the course, but not super advanced or something like that
@gttrackpro9433
Ай бұрын
@@ByteGrad ok got it. going to purchase your course asap 🎉
Github link?
What vs code theme do you use? It's great
@umernasir4217
Ай бұрын
Please tell me as well.
@AvikNayak_
Ай бұрын
Maybe Andromeda
@heismyke
Ай бұрын
He doesnt like to tell people what theme he uses. i have been asking him too for a long time
god bless you...
🙏
6:33 Why doesn't it appear to me the autocomplete? I have the Prisma extension already installed
@mustafamufeed1666
Ай бұрын
+1
@viundesign
Ай бұрын
Still wondering
@viundesign
23 күн бұрын
@@mustafamufeed1666 Git Hub Copilot
@viundesign
20 күн бұрын
@@mustafamufeed1666 Git Hub Copilot
@suphawatwong9438
9 күн бұрын
@@viundesign it's co-pilot feature, i guess
Would be very helpful to understand why the data sometimes disappears when the schema is changed? Anyone know why it happens? Thanks a lot
@emad_naeim
Ай бұрын
if the old data violates the new schema you make then it will be deleted (it will tell you and warn you before that), like if you are going to add new column and that column is required.. and you didn't specify the default value.. then by default old data will be deleted because they don't have value for this new colum. as a hack when you are playing with schema and you want to add new column.. specify a default value.. then it won't delete old data
@A28480
Ай бұрын
@@emad_naeim thank you very much
@emad_naeim
Ай бұрын
@@A28480 😇🤍
what if a post could have multiple categories and tags
I may be wrong but I don't think you talked about security and authorization which would have been great
45:52 what was that sound :)
The hardest thing that i dealt with prisma schmea until now was adding multi language support. Tried so many ways and ended up with using json for storing the values Not happy with this solution and looking for better ways, ill be appreciated if someone can help me with this
@sorenbs1
Ай бұрын
I’ve always implemented this by loading the full translation file as json and caching it in memory on the server. That way loading the replacements is super cheap.
revalidatePath does not work
why not drizzle
@bibblebabl
Ай бұрын
If you think you ready to try it - go for it. It’s not exactly the same and it has less abstractions AFAICT. So basically you will need better understanding of SQL because drizzle gives you more control since it’s more a query builder. Now it becomes more popular but I guess not all people understand that it requires some entry level when with prisma you don’t have to care about a lot of things
@jonbharrell
Ай бұрын
@bibblebabl is completely right. Prisma and Drizzle are similar tools at different levels of abstraction. If you prefer the Drizzle way of defining your models and querying, then it is the right tool for you.
This guy must be Dutch to speak English this clearly and quickly while multitasking. He definitely isn't British or American anyway, his English is too good.
alright let's start the war 🚀 Prisma VS Drizzle
Pls drizzle
Switched to drizzle
i find primsa to be pretty horrible tool, the fact that we all opt out writing SQL is just mad. ORM creates stupid developers which cannot write proper SQL which creates TONS of problems later on
@true227
7 күн бұрын
i'm totally agree