Prisma - The Easiest Way to Work with a Database in Next.js (UPDATED)
HTML-код
- Опубликовано: 11 сен 2024
- Prisma is an ORM and database toolkit which makes it easy to have type-safe database access in Node. It's also the easiest way to work with databases in a Next.js app. You can learn more at prisma.io/nextjs.
In this video, we look at how to integrate Prisma in a Next.js app. We see how to query for data in the getServerSideProps function and how to save data using an API route.
Demo App Repo: github.com/che...
------------------------
Next:
👉 Check Previous video: How to create a PostgreSQL Database with Prisma's Data Platform - • How to create a Postgr...
👉 Check Next video: Seeding Databases with Prisma - • Seeding Databases with...
------------------------
📚 Resources:
✅ Subscribe to Prisma: / @prismadata
✅ Get help from the Prisma Community: slack.prisma.io/
✅ Learn more about Prisma:
◭ Website: www.prisma.io
◭ Docs: www.prisma.io/...
◭ Quickstart: pris.ly/qstart
------------------------
💬 Connect with Prisma:
Twitter: / prisma
Instagram: / prisma.io
TikTok: / prismadata
Facebook: / prisma.io
LinkedIn: / prisma-io
------------------------
Prisma sponsors human-reviewed, professional closed captions for ANY video valuable to our community (for example, about: Node.js, TypeScript & Type Safety, Prisma, databases, etc). Get your FREE captions here: pris.ly/closed...
Would be cool to see whats the best way to use authentication and authorization with next and prisma… :)
Yes
YES
@@neoesm agree
Yes
Magic Link maybe
This guy should do all Prisma tutorials. Awesome.
Big thumbs up, this guy explains very well and his attitude is great while explaining
He sounds like a private detective
Great overview. Love this!
Thanks James 🙌
Huge thumbs up for this video, very concise, helped me A LOT with getting started with Prisma.
Thanks! This channel needs more videos like this one.
From a very new Nextjs developer, I would love to see a tutorial from the very beginning. This is a great video but there is too much code for me to really understand it. Don't get me wrong, I could copy and paste and get it working but to really learn, a tutorial from the very start would be great.
Very interesting technology! Thanks!
Awesome!
1:00 didn't know that. That's really cool.
Excellent video, Ryan. Thanks!
At the ~7:45 mark, you mention a video that shows how to use a singleton rather than instantiating the Prisma Client in various places in the app. Can you post a link?
Also me looking for this link
@prisma
I think this video from prisma can help : ruclips.net/video/aim8Mk-ETK0/видео.html
Thank you for the video, you explains very well
You are welcome! We're glad it was helpful! 💚
pretty useful and practical tutorial !!!
Very good and informative tutorial - I'm just sitting back and missing the last step of how to deploy it...
I need help on that too
Great tutorial video. Very concise and to the point.
Whats the best way to learn how to model or design prisma 2 databases? I would like to see examples and / or tutorials on more complex databases. Thanks in advance
Thanks for the video! I'm curious if there is a "Prisma way" to add triggers to Postgres? Or do you just have to do it manually through raw SQL?
nothing specific that I know of. I was just looking for any docs we have but I can't find much. I believe right now it's just a manual task. Feel free to open an issue about it though, perhaps this is something that can be looked at in the future :)
Awesome! Thanks for the reply. I couldn’t find anything either. So I’ll open an issue up. 🙏
13:05 that is a DTO for creating the actual model of Contact, to speak in software development parlance. :)
But it is a simple generated type that probably looks identical to Contact itself. People might want to create their own DTOs so they can implement business logic like validation and such.
react-hook-form updated to 7.0.0 from 6.X.X and has breaking changes
Where is the link to the video you discussed at @7:45
Here it is: ruclips.net/video/tsOHw2T1HvI/видео.html
I'm following that approach github.com/prisma/prisma/issues/1983#issuecomment-869036852
Amazing video, just what I needed. Thanks! You've +1 subscriber
This should be updated react-hook-form v7 has breaking changes!
I wish i could like a video multiple time lol
Thanks, good course for me :)
This is amazing!
6:43 I'm getting an error here
when trying to import the { initialContacts }, I get
"Binding element 'X' implicitly has an 'any' type."
any help?
forgive my ignorance. If the api routes are run on the server, how are they "serverless functions"?
The term Serverless functions is indeed confusing. In practice, it just means that you don't need a dedicated server. There's always going to be a server that actually runs the functions - they are just invisible to you.
Yes, I use Next js with Prisma and mysql database and it is good combination for full stack developer but I have an issue to deploy on hostinger as it pre installed the phpmyadmin or database but didn't know about how we deploy my next js project on this and how can I create the tables in database dynamicallly.
(if you have any reference for me you can send me)
Why have you styled your hair like a RawR Xd girl from the early 2000s? Great video thanks.
Hi Ryan, is there a support for multi-tenants based app?
Cuando ejecuto npx prisma studio obtengo este error "Error: spawn undefined\System32\WindowsPowerShell\v1.0\powershell ENOENT" me podría ayudar a solucionarlo gracias
Prisma best
Got anything for SQL Server with Windows Authentication?
Hi there Ryan, I have a quick question, I never used SQLite before so I'm not sure whether it's safe to push the dev.db file to a public repo or not, I love the idea of having a ligth db in the file system but I obviously don't want to expose my application's data. Thanks in advance!
The idea behind database migrations is to "rebuild" your database when you run them. So storing any kind of database file in version control is a bad idea, even if the data isn't confidential. Use migrations and seeders to rebuild the data, or opt for a hosted database. Of course, you can still use SQLite if you don't mind mainting the sqlite file locally.
Is this prisma thing an alternative to mongoose? and would it make sense to use mongoose and prisma on a single project using mongodb?
Hey Prisma! Just out of curiosity, what is your revenue generation model / how does prisma make its money? Looking to adopt something like prisma but want to make sure it will be around for a while!
Prisma is open source and using it is free of any charge! In the future, Prisma will offer additional cloud services to facilitate various database- and Prisma-related workflows. Note that these will be optional, Prisma can continue to be used without consuming any commercial services.
Thanks for your video, it helps me a lot. After everything is done, I have a question: can we deploy it to vercel directly with local ./dev.db. It seems not working.
same, how should we do it lol
how to configure prettier to format thing like that?? 3:50
is there a difference between prisma migrate dev and prisma generate?
Yes.
The prisma migrate dev command generates SQL migrations and executes them
The prisma generate command generates the Prisma Client code that you import into your application.
Have you any beautiful .prettierrc file for your style (without semicolon and align your model names) ? 😇
What is that icon theme?
Something which I hate is that often times there is a ease of use way of doing things which is different from the actual way of doing things like the singleton pattern of the client. I wish the library would just deal with it.
Hey what font is that?!
Hi! How can I update database without erase data. For example I want to add new column.
Just change whichever model(s) within the schema.primsa file and run npx prisma migrate dev. It will auto sync the new updated schema with your database. Don't forget to run prisma generate when you're finished to resync the database with @prisma/client
If you are going to use shared hostings, cpanel to host the app, do not use prisma. Prisma cannot work on ubuntu 20.04 at all. Its been lot of time. They have not fixed the issue.
How do I update the Schema so i can add a new model or change model fields?
Hey Chris! You can make changes to your schema and then use Prisma migrate so that the changes are reflected in your database 😄
Check out the docs here: www.prisma.io/docs/concepts/components/prisma-migrate
what is Prisma and why should i use it ?!😅
Does prisma support graphql? When will mongodb be ready?
Hello there! To answer your questions:
(1) Prisma and GraphQL fit together very well - Prisma is an ORM that is used inside of GraphQL resolvers to query a database. More info here: www.prisma.io/graphql
(2) Prisma currently supports MongoDB in Preview and we plan to launch the GA support by the end of the year. More info here: www.prisma.io/blog/prisma-mongodb-preview-release
Hi there, why is this happening? Error: Error serializing .postsreturned fromgetStaticPropsin "/posts". Reason:object ("[object Promise]") cannot be serialized as JSON. Please only return JSON serializable data types.
looks like you have a page called "posts"? from the error, it looks like it could be that you're not awaiting something. if you're making a call to prisma to get data, be sure to await it so you can get the actual data result and not the pending promise.
@@holodeck_run I'm pretty sure I am set it to await, but still get this error.
@@elshir hard to say from just the error message. if your code is in a repo where I can take a look, I might be able to find the issue.
@@holodeck_run I got it, because of time.
I m using mongoose. I never use prisma before. Please upload tutorial how I can use authentication and authorization with next js and prisma in API route
Check out this course which includes authentication and authorization with Next.js and Prisma: www.prisma.io/blog/fullstack-nextjs-graphql-prisma-oklidw1rhw
@@PrismaData Thank you
bro, i thought Sam Altman was going to teach us.
Prisma has a nasty surprise that Prisma developers don't give a damn about, when transferring a project from one development environment to another where there is no Internet, Prisma tries to download a new driver for its work, if you have tight security settings, consider that your project will not work. Because of this, I almost lost my job. Gentlemen, can you create an offline version for complex situations !!??
please JS version
now show us your middleware
downvoted
一
If I understand correctly, you have renamed @prisma/cli to just plain prisma. If that is correct, I am wondering why you changed the name. @prisma/cli is much more descriptive of what the package does then just plain prisma (particularly since there is still a @prisma/client package).
Hi Ryan, I'm following one of the examples from Prisma Github page and i just wanted to know what is the .author() does in these code, Thanks.
author: (parent, _args, ctx) => {
return ctx.prisma.post
.findUnique({
where: { id: parent.id },
}) .author()