Can you point me to and docs or fourms on how to do this? Beating my head against the wall just trying to get a simple db connected to by next app! I was trying with AWS RDS first with no luck and now moved to planetcale and still cant get it figured out.
It's not in the docs, but someone already made a PR for it a few weeks ago. It should get merged on the next release probably, unless its already been.
Is there a video somewhere that explains the Prisma "multiple table read" issue? I can't seem to get my head around Prisma's popularity if it actually makes people incur a much larger cost for row reads/requests. I cant see how or why anyone can afford Prisma scale if it is actually performing more reads per join than Drizzle.
i also hopped on to the drizzle hype train. upgrading my project from the layout i had which was similar to Theo's Chirp app was much more confusing than i thought. took me very long to understand that the drizzle call had to be done server side, and in react router, everything in my app was treated as client side. in new app dir i managed to get a much better separation of client and server. if anyone has trouble upgrading their chirp-clone from prisma to drizzle, i highly recommend using next 13.4 app dir and ask questions to communities if needed!
@@joshtriedcoding as someone who was just getting into the t3 stack and nextjs in general, prisma made it seem too easy, and i began to run my drizzle queries on client using public env variables until i realized that is NOT the way. atleast the switch to drizzle helped me become for familiar with the environment as a whole and how it works
Josh, i have tried drizzle and it's amazing by the moment. In your video you missed an important information and it's that it doesn't have an official stable release and you could find some weird behaviours for example in my case i have tried the new relations model that they released on version 0.26 y it works fine for one to many relations queries but fails backwards for example if you have a users and posts table you can ask for the user and his posts, but if you ask for a post and his user fails with some weird error. Thanks for your video anyways, keep it up.
I used Drizzle and it isn't a Prisma killer simply because it's not really meant tor replace Prisma. I would say for very simple simple project, Prisma is fine since it has enough functionality and it can deal with SQL and NoSQL databases with the same dialect. Drizzle is only for SQL and each provider (Postgres, MySQL, etc) have their own slightly different dialects which only matters for large projects where you are using these advanced features.
This is excellent. I'm sure you have this planned, but can you do a video showing how to add to the schema? Like, I have another column that I need to add to an existing table. Or let's say I need to change the type of a column from a varchar(255) to text. How would that work with the migrate method?
i've never tried drizzle but i'm interested in doing so, but i will respond based on my mysql knowledge , as far as i know text is almost the same as using varchar(65535) which is really big and inefficient, i wouldn't recommend using it unless you don't have other option, the more the varchar value is big the more it consume memory and storage space, and even for a phone number varchar(255) is a bit overkill, hope you get what i mean
Thanks again for all your information ! You really simplify my drizzle setup where I was using the database name, user, password and other envs hahaha. Was having trouble with that and the SSL certificate but your setup works as charm! Is there any advantage of running first the migrations and then pushing? Since I was directly pushing to planetscale without migrations 🤔
@@joshtriedcoding I mean, i just have a drizzle:push command that reads the config and pushes directly to planetscale, without runing manually the generate. "drizzle:push": "drizzle-kit push:mysql --config drizzle.config.ts" where the config its almost the same as yours, without the out: const config: Config = { schema: "./src/server/db/schema/*", connectionString: process.env.DATABASE_URL, }; I was wondering if the generate had anything I'm missing 🤔
One very important thing to note on Planetscale. You should index on userId foreign column. Prisma vscode extension does this automatically when using relationMode prisma.
with node js there is no need to fetch data at one, because network request are non blocking so few round trips database would have no effect, in django whiel the data is being fetched from the db, its just sitting duck and waiting for data to arrive, while node can handle some other task, also "select_related" are "prefetch_related" are basically joins and many ORMs except the fraudulent "prismaORM" have proper joins.
Hi Josh, great video I love the content. do you think you could do a video on how to call the dbs directly in a server component and how to properly implement On demand re validation in these cases? Keep up the great work
Ok after few weeks seeing your videos in my feed and watching them... i approved your content and energy and decided to subscribe 🙂 keep up coding Josh
Not so long ago, I moved on from Sequelize and embraced Prisma having heard all sort of great things about it but now there’s a new kid on the block and all I hear is not so great things about Prisma
None of these is "good" or "bad" per se, they shine in very different use cases. Prisma is awesome for getting started and having a simple and clean DX. Drizzle is awesome for embracing all benefits of sql, postgres, ... with their performance advantages, but not so much suited for beginners because it does add overhead if you're just trying to learn the underlying technology such as Next
@@joshtriedcodingyea well said. I’m a performance freak. I get pressured when I know there’s a more performant alternative to what I’m using. Drizzle will have to wait until my next project cos I’m all in with Prisma atm. Thanks for the vid.
Thanks for the video, good stuff. I love Dizzle too. Why are you generating migrations here though? The point of push with planet scale is not to use migrations and instead use it’s inbuilt branching.
Love the videos man but it would be nice if your titles/thumbnails were a bit more descriptive. I thought this was a prisma video and almost skipped it! I was hoping you were gonna do a Drizzle video!
Hey Josh We need one video where you compare working of drizzle and prisma under the hood like about their query engine I do know about prisma but dont have any idea about drizzle orm.
It's mostly DX and type-safety. - No classes (experimental decorators etc.) - Helpers for inferring the types for selects and inserts - Takes advantage of generics to properly propagate the types from end-to-end
Why can't I just find a PostgreSQL query builder for a Typescript NextJS project. Something worth using in a startup production app? All I find are ORMs that are either in beta or not flexible or not even mature. Or document based databases, does JavaScript just hate SQL that much? Maybe I don't know, tell me something that suits this criteria, coz man 🤦🏾♂️🙆🏾♂️ I've been searching for what feels like forever
Hello Josh! I have a problem with Next Auth middleware. I can not find answer in internet. When i make simple next auth code and then try use middleware i get error: ./node_modules/next-auth/next/middleware.js Module parse failed: Identifier 'NextResponse' has already been declared (3:6) | "use strict"; | const NextResponse = require("next/dist/server/web/spec-extension/response").NextResponse; > const NextResponse = require("next/dist/server/web/spec-extension/response").NextResponse; I tried rewrite code from begin but i still get it. If u have a time or know how to solve this problem, can u help me pls?
To all of you who want to start using drizzle orm as theo or josh said it. It is not mature doesn't have a adapter for the planet scale database with next auth as prisma does nor has as refined docs, unsigned integer or as big of a community . Right after this video was released planet scale introduced the scaler pro plan where you have unlimited read and write which mitigates the cost issue. starting from $39 it can go up to $999 8 vCPU and 32 GB RAM in AWS which much be sufficient for almost all use cases and vast majority of people. If you need more than this you are already a multi million dollar company and that's that. Untill Drizzle goes to version 1 I am waiting and will go with prisma and planetscale.
fair point. drizzle is very fun and refreshing to use, but not very established. While I think that will change in the not so near future, there's absolutely nothing wrong with prisma
@@joshtriedcoding does it actually have big performance improvement over prism or just a minute difference. Right now I am working on a client work and i have a scenario in which I have do to many to many relation , and it is slow in prisma, as it is taking around 4s to to create it in database . Do does drizzle actually make a difference?
everybody is saying drizzle is great and everybody is saying it's not -.- even the tweets they have on the website are saying that so not really sure this time
its just the typical "this new thing is not exactly like my old thing, so its bad >:(" had this in minimal api's in dotnet, people were going "this is cluttered and messy". well, news break: just do multiple files, its about the faster framework
How come you're connecting through @planetscale/database but providing only a db url instead of db host, username and password? EDIT: nvm I just read the database-js documentation
The starter kit: github.com/joschan21/drizzle-planetscale-starter I feel like this makes trying drizzle way easier
Could you add an auth example with nextauth or clerk?
Drizzle is great. I genuinely believe every developer needs to know SQL. This is just how you optimise your application.
I would say not only SQL, but all that stuff about indexes, sargable and non- sargable queries, etc.
Drizzle is not great, it have broken migrations workflow
if you code ur project with unique indexes every single time you can, your project will be super fast, whether you use prisma or not.
Can't wait for "Josh tried Horsing"!
Hahahha I wonder what the video content would be
Something with PHP maybe
I was not expecting that line and it got me good 😆
It was pretty easy to swap out Prisma with Drizzle in my create-t3-app project
Do you use next-auth in your create-t3-app project? Because i'm afraid of have issues combining drizzle with next-auth
@@jacob7785 I don’t, I’m using Clerk. Not sure what the implications would be for next-auth
Why not using both in the same repo?
For Planetscale you should be using the db-push command from drizzle-kit and the PS database schema branch pull request/merge
Can you point me to and docs or fourms on how to do this? Beating my head against the wall just trying to get a simple db connected to by next app! I was trying with AWS RDS first with no luck and now moved to planetcale and still cant get it figured out.
The only thing this orm is lacking is its next-auth adaptor. If that gets released quickly it will be a joy to work with this
It’s out already
@@yiannis_p no it's not I checked the next auth docs
If there was an authjs adaptor, I would 100% choose Drizzle. But now I'm unsure.
It's not in the docs, but someone already made a PR for it a few weeks ago. It should get merged on the next release probably, unless its already been.
@@dan_____ They had released it but drizzle made some braking changes and then they are again rebuilding it.
Is there a video somewhere that explains the Prisma "multiple table read" issue? I can't seem to get my head around Prisma's popularity if it actually makes people incur a much larger cost for row reads/requests. I cant see how or why anyone can afford Prisma scale if it is actually performing more reads per join than Drizzle.
Same seems absolutely unreal if they really are doing that.
Why not using both? Prisma for DX and Drizzle only in the queries where Prisma is slow? They don't affect the bundle
i also hopped on to the drizzle hype train. upgrading my project from the layout i had which was similar to Theo's Chirp app was much more confusing than i thought. took me very long to understand that the drizzle call had to be done server side, and in react router, everything in my app was treated as client side. in new app dir i managed to get a much better separation of client and server. if anyone has trouble upgrading their chirp-clone from prisma to drizzle, i highly recommend using next 13.4 app dir and ask questions to communities if needed!
Ah interesting, yeah database queries cannot be done on client components. NextJS really makes this super straightforward
@@joshtriedcoding as someone who was just getting into the t3 stack and nextjs in general, prisma made it seem too easy, and i began to run my drizzle queries on client using public env variables until i realized that is NOT the way. atleast the switch to drizzle helped me become for familiar with the environment as a whole and how it works
Javascript developer discovering tools that have existed for more than a decade.
Josh, i have tried drizzle and it's amazing by the moment. In your video you missed an important information and it's that it doesn't have an official stable release and you could find some weird behaviours for example in my case i have tried the new relations model that they released on version 0.26 y it works fine for one to many relations queries but fails backwards for example if you have a users and posts table you can ask for the user and his posts, but if you ask for a post and his user fails with some weird error.
Thanks for your video anyways, keep it up.
Cheers man. Haven't stumbled upon any weird behavior for that myself but thanks for pointing it out
Unfortunately, drizzle kit:push postgres is not available atm😢. Migration in postgres is not as handy as mysql.
is there any adpater for drizzle for next-auth?
I used Drizzle and it isn't a Prisma killer simply because it's not really meant tor replace Prisma. I would say for very simple simple project, Prisma is fine since it has enough functionality and it can deal with SQL and NoSQL databases with the same dialect. Drizzle is only for SQL and each provider (Postgres, MySQL, etc) have their own slightly different dialects which only matters for large projects where you are using these advanced features.
This is excellent. I'm sure you have this planned, but can you do a video showing how to add to the schema? Like, I have another column that I need to add to an existing table. Or let's say I need to change the type of a column from a varchar(255) to text. How would that work with the migrate method?
i've never tried drizzle but i'm interested in doing so, but i will respond based on my mysql knowledge , as far as i know text is almost the same as using varchar(65535) which is really big and inefficient, i wouldn't recommend using it unless you don't have other option, the more the varchar value is big the more it consume memory and storage space, and even for a phone number varchar(255) is a bit overkill, hope you get what i mean
Would love to implement drizzle with next-auth eventually but I'm a bit scared I'll break something lol
Thanks again for all your information ! You really simplify my drizzle setup where I was using the database name, user, password and other envs hahaha. Was having trouble with that and the SSL certificate but your setup works as charm!
Is there any advantage of running first the migrations and then pushing? Since I was directly pushing to planetscale without migrations 🤔
Happy to hear that man! Not 100% sure what you mean, when "pushing", you are always pushing *something* - in this case the sql migrations
@@joshtriedcoding I mean, i just have a drizzle:push command that reads the config and pushes directly to planetscale, without runing manually the generate.
"drizzle:push": "drizzle-kit push:mysql --config drizzle.config.ts"
where the config its almost the same as yours, without the out:
const config: Config = {
schema: "./src/server/db/schema/*",
connectionString: process.env.DATABASE_URL,
};
I was wondering if the generate had anything I'm missing 🤔
One very important thing to note on Planetscale. You should index on userId foreign column.
Prisma vscode extension does this automatically when using relationMode prisma.
I wish more ORMs would take a similar approach as the Django ORM. It is really easy to optimize at scale with `select_related` and `prefetch_related`.
with node js there is no need to fetch data at one, because network request are non blocking so few round trips database would have no effect, in django whiel the data is being fetched from the db, its just sitting duck and waiting for data to arrive, while node can handle some other task, also "select_related" are "prefetch_related" are basically joins and many ORMs except the fraudulent "prismaORM" have proper joins.
btw, planetscale does not offer a free tier any more. that's too bad. neon (postgres) still works.
is there a need to use zod with server action? do we still need to type check the inputs?
Hi Josh, great video I love the content. do you think you could do a video on how to call the dbs directly in a server component and how to properly implement On demand re validation in these cases? Keep up the great work
Is this ready to be used in a production app?
Ok after few weeks seeing your videos in my feed and watching them... i approved your content and energy and decided to subscribe 🙂 keep up coding Josh
Not so long ago, I moved on from Sequelize and embraced Prisma having heard all sort of great things about it but now there’s a new kid on the block and all I hear is not so great things about Prisma
None of these is "good" or "bad" per se, they shine in very different use cases. Prisma is awesome for getting started and having a simple and clean DX. Drizzle is awesome for embracing all benefits of sql, postgres, ... with their performance advantages, but not so much suited for beginners because it does add overhead if you're just trying to learn the underlying technology such as Next
@@joshtriedcodingyea well said. I’m a performance freak. I get pressured when I know there’s a more performant alternative to what I’m using. Drizzle will have to wait until my next project cos I’m all in with Prisma atm. Thanks for the vid.
it does not allows the repetition of a table name in different schemas. This is blocking for multischemas multitenant apps
so every time the schema is modified, do we need to regenerate sql and repush?
Thanks for the video, good stuff. I love Dizzle too.
Why are you generating migrations here though? The point of push with planet scale is not to use migrations and instead use it’s inbuilt branching.
How about a next-auth adapter? Is there any implementation at this point?
Love the videos man but it would be nice if your titles/thumbnails were a bit more descriptive. I thought this was a prisma video and almost skipped it! I was hoping you were gonna do a Drizzle video!
Defined a many-to-many relation in Drizzle. Looked at the code. Installed Prisma.
do we still need some kind of prisma proxy alternative?
Great content Josh! What are your thoughts regarding Postgres vs MySQL vs nosql for a multiuser use case?
Hey Josh We need one video where you compare working of drizzle and prisma under the hood like about their query engine I do know about prisma but dont have any idea about drizzle orm.
What's the difference between this and typeorm?
It's mostly DX and type-safety.
- No classes (experimental decorators etc.)
- Helpers for inferring the types for selects and inserts
- Takes advantage of generics to properly propagate the types from end-to-end
Why did you omit the fact that relations in drizzle is a PITA?
Hey Josh, super cool. Kinda reminds me of typeorm
dude what u think about pocketbase
Sir is React and Next js turned into PHP??
0:24 Heey I used ''unmatched DX'' in my last comment to your prisma video :D
Is there a tool for modify table? For example add a column. Push overrides database and ypu lose all data.
So I can use it with Vercel Edge functions out of the box?
yes
Why can't I just find a PostgreSQL query builder for a Typescript NextJS project. Something worth using in a startup production app?
All I find are ORMs that are either in beta or not flexible or not even mature. Or document based databases, does JavaScript just hate SQL that much?
Maybe I don't know, tell me something that suits this criteria, coz man 🤦🏾♂️🙆🏾♂️ I've been searching for what feels like forever
Ofc after i done learning prisma
Hello Josh! I have a problem with Next Auth middleware. I can not find answer in internet. When i make simple next auth code and then try use middleware i get error:
./node_modules/next-auth/next/middleware.js
Module parse failed: Identifier 'NextResponse' has already been declared (3:6)
| "use strict";
| const NextResponse = require("next/dist/server/web/spec-extension/response").NextResponse;
> const NextResponse = require("next/dist/server/web/spec-extension/response").NextResponse;
I tried rewrite code from begin but i still get it. If u have a time or know how to solve this problem, can u help me pls?
It's an interesting topic, I'll try it.
To all of you who want to start using drizzle orm as theo or josh said it. It is not mature doesn't have a adapter for the planet scale database with next auth as prisma does nor has as refined docs, unsigned integer or as big of a community .
Right after this video was released planet scale introduced the scaler pro plan where you have unlimited read and write which mitigates the cost issue. starting from $39 it can go up to $999 8 vCPU and 32 GB RAM in AWS which much be sufficient for almost all use cases and vast majority of people. If you need more than this you are already a multi million dollar company and that's that.
Untill Drizzle goes to version 1 I am waiting and will go with prisma and planetscale.
fair point. drizzle is very fun and refreshing to use, but not very established. While I think that will change in the not so near future, there's absolutely nothing wrong with prisma
is this starter kit outdated by any chance? Is it just me getting the connectionString does not satisfy the config type error in drizzle.config.ts?
It’s absolutely unreal that Prisma does that. Like that’s all been figured out in the PHP days why are they doing that?
Nice video, can you do a video with drizzle and next-auth please 🥺, thanks 🙏
Is drizzle good for postgres ?
Yeah works with that
@@joshtriedcoding have to tried it with trpc ?
@@joshtriedcoding does it actually have big performance improvement over prism or just a minute difference.
Right now I am working on a client work and i have a scenario in which I have do to many to many relation , and it is slow in prisma, as it is taking around 4s to to create it in database .
Do does drizzle actually make a difference?
Can i use drizzle with supabase? Somebody tested?
just finished learning prisma, damn it🥺
protect n serve lord farqaad
Push command not recommend in docs ... Better to use migrate
Every month we should rewrite our codebases as there’s a “new kid on the block”.. Vercel ecosystem has something off..
Drizzle looks very good 🙌 Why Prisma doesn't work on the edge, but Drizzle does? 🧐 I'm still not confortable with Edge runtime and what it means
I think I must revise my SQL notes and cheatsheets.
Man just the same for me. The last real SQL query I've written before this was like a year ago and I felt like a grandpa getting into drizzle
@@joshtriedcoding lol
Hi, I’m the 1% 😂🙋🏻♀️ I’m definitely going to swap out Prisma for Drizzle at some point, but Prisma is just so easy at the moment.
It's all the hype
why not prisma? because no esm
8.75 seconds to create a user?
More videos about DrizzleORM PLease
Drizzle it is and get to get more comfortable with SQL ? Challenge accepted
A new fullstack project with drizzle pleas JOSH
another JS ORM. I wish someone create an opensource JS enterprise edition where we can have standardized toolbox maybe similar to spring.
You could put "Drizzle" in the title, but I guess that wouldn't be click-baity enough?
Please create a video tutorial of real projects using drizzle josh 🤘
Currently prototyping now…
How long before you and your AI friends take over our jobs, Josh?
can you please make a tutorial for Next js and planetscale.
DrizzleORM looks more intuitive.
It does if you know SQL, it doesn't if you don't
can you make your videos 60fps?
Raw SQL > SQL builders >> ORMs.
I'm starting to feel this way but then I can't enforce my types 😥
I wish to see SQLite starter 😊😊
Drizzle is good but firebase and App write are too good for database and hunny thing is that I never use App write but rode about it 😅
I don't know what's going on over at YT but I've been unsubscribed from your channel not once, but twice now! I have no idea why it's happening.
man what the hell youtube
everybody is saying drizzle is great and everybody is saying it's not -.- even the tweets they have on the website are saying that so not really sure this time
its just the typical "this new thing is not exactly like my old thing, so its bad >:("
had this in minimal api's in dotnet, people were going "this is cluttered and messy". well, news break: just do multiple files, its about the faster framework
Man the tweets on their website are a joke :D
@@joshtriedcodingthat's where they bought me 😂
@@joshtriedcoding they got me haha but why is that, like why somebody would deliberately undermine their reputation?
@@joshtriedcoding They're actually true tweets, but Drizzle team has their meme game top notch
Javacript community makes my eyes bleed. Always something new. Shiny Object Syndrome community. Next week this will be replaced as well.
I hope prisma be replaced
Wtf, I hate Prisma now!
I'm more like noSQL world
State of js shows there's a significant amount of non binary developers, most of whom are male, yes. 😅
why u changed :
"migrations:push": "node -r esbuild-register src/lib/db/migrate.ts",
?
How come you're connecting through @planetscale/database but providing only a db url instead of db host, username and password?
EDIT: nvm I just read the database-js documentation