Drizzle allows you to select only what you like inside the select. select({posts}).from(…. Or be even more specific with select({id: posts.id}).from(…. Which is a bit nicer on your db. Great demo
Exactly, maybe the idea was to keep the video short (which is great btw), but for these kind of quick tips, it might make sense to do it the right way as a lot of people especially juniors will use this as a tutorial and not a demo. Thanks for the content.
Being able to exactly specify which fields you want back from your query in your select makes this so so powerful, saving payload size and not sending data to the frontend (or in this case the results variable) with typescript understanding it is soooooooo good
From a practical standpoint does this really save that much data, I feel like data is generally on the kb order of magnitude, and sending data over the wire has generally not been a limiting factor in the speed of my app.
I've tried Drizzle but I struggled a LOT with the typing. You can infer a type from a schema but infering types from queries (even more when doing joins) is a big mess to me. Would love to see a video about that!
I actively use SQL for work and I always struggled using ORM's like Entity Framework etc. First time in my life I saw a ORM which is exactly looks same to SQL and very easy to use for SQL Experienced person like me. Thank you for the video!
I'm loving Drizzle for querying. Now I'd truly love a tutorial on how to handle migrations on a project with Drizzle and Supabase. Still trying to wrap my head around it
Can you talk about how you like to structure your API's data layer. Coming from java I have been enforced to use service/repository patterns for a long time but I'm unsure if I actually like it for nodejs
personally, the day I moved from Prisma to Drizzle was when I inspected generated sql queries with some joins. Prisma generated several db queries and joined them "internally". Drizzle creates a single db query. There might be technical explanation why this is not bad, but it goes against all my believes of handling relational databaes and I simply cannot stand it innmy code. And drizzle magic sql `` is amazing
This is very similar to C# LINQ and a lot of ORMs for it like core or NHibernate(also java). The only thing I always worry about it how much this expose the database
Don't know how this works in drizzle but would it not be preferable to only select the posts directly in the query rather than fetching all columns and then essentially filtering out the columns?
Hey there...love the vids. A question tho...I took a look at your implementation of "database" in your SAAS project on github and was wondering why you stored the db instance in a global variable (. (global as any).database=....) when in dev mode but not in production? What's different about dev mode that makes it a good idea to do this?
Hey Cody, could you help me with an issue? I'm trying to set up drizzle with aws rds in postgres, but when I'm trying to push my tables, drizzle can't find my region, even though they are inside the DATABASE, SECRET_ARN and RESOURCE_ARN env variables?
I m having a terrible time with drizzle migrations. there is no way to rollback a migration at the moment. the only way is to update/edit migration files or drop database. no one is covering these aspects of a production application.
They are currently working on a rollback for migrations. Currently the approach is to revert your scheme of file and generate another migration script and then apply it to revert the changes.
drizzle orm is one of the few javascript libraries that deserves the hype. it's actually good. unlike everything else in that ecosystem that has hype and is not very good.
Think this has been possible in prisma since day 1 no? but you can just use the regular TS stuff, dont need to use raw sql, but you can if you want I guess (edit: or is this whole video just bait to get prisma users to interact, if so, nicely done)
@@rod6722 I guess it comes down to personal preference tbf. The syntax in prisms schema files look way cleaner than creating a schema using TS for drizzle. Plus you don’t actively use the schema file anyways, so as long as the rest of prisma functionality is in TS, then it’s good. And again, it’s all personal preference
Love the shorter and more specific videos!
srtaight to the point!! I'm loving the path this channel has taken, good stuff bro!!
no matter how fast we are, your wife will always be first
😂😂😂love this
Drizzle allows you to select only what you like inside the select.
select({posts}).from(….
Or be even more specific with
select({id: posts.id}).from(….
Which is a bit nicer on your db.
Great demo
Exactly, maybe the idea was to keep the video short (which is great btw), but for these kind of quick tips, it might make sense to do it the right way as a lot of people especially juniors will use this as a tutorial and not a demo.
Thanks for the content.
Exactly what I wanted to say.
Being able to exactly specify which fields you want back from your query in your select makes this so so powerful, saving payload size and not sending data to the frontend (or in this case the results variable) with typescript understanding it is soooooooo good
From a practical standpoint does this really save that much data, I feel like data is generally on the kb order of magnitude, and sending data over the wire has generally not been a limiting factor in the speed of my app.
@@BenMargoliusit’s not a trivial amount at scale
Prisma support this easily without a sweat. Where it lacks a bit are advanced usages of aggregates.
Thanks for letting me know
Good job babe!!!! First yeaaaaaa 👸🏽
Thanks my number one!
i swear, i never new you were his wife.. Good for you guys, i'm getting married next year too, i can't wait
@@stanleychukwu7424 She literally comments on every single one of his videos. Pretty cool 😎
This is so wholesome
Prisma has been able to do that for years. In a much simpler way (imo) too.
I've tried Drizzle but I struggled a LOT with the typing. You can infer a type from a schema but infering types from queries (even more when doing joins) is a big mess to me. Would love to see a video about that!
I actively use SQL for work and I always struggled using ORM's like Entity Framework etc. First time in my life I saw a ORM which is exactly looks same to SQL and very easy to use for SQL Experienced person like me. Thank you for the video!
What keyboard are you using? It sounds really nice
I'm loving Drizzle for querying. Now I'd truly love a tutorial on how to handle migrations on a project with Drizzle and Supabase. Still trying to wrap my head around it
I'd love to see the actual generated query
Much love as always from Uganda "mentor"...
Thanks man
Make a crash course on complex sql query using drizzle ORM. Love to see your contents
Can you talk about how you like to structure your API's data layer. Coming from java I have been enforced to use service/repository patterns for a long time but I'm unsure if I actually like it for nodejs
personally, the day I moved from Prisma to Drizzle was when I inspected generated sql queries with some joins. Prisma generated several db queries and joined them "internally". Drizzle creates a single db query. There might be technical explanation why this is not bad, but it goes against all my believes of handling relational databaes and I simply cannot stand it innmy code. And drizzle magic sql `` is amazing
I just started using drizzle and turso for my new project and it makes using sqlite so much better in typescript
This is very similar to C# LINQ and a lot of ORMs for it like core or NHibernate(also java). The only thing I always worry about it how much this expose the database
prisma definitely supports this
Don't know how this works in drizzle but would it not be preferable to only select the posts directly in the query rather than fetching all columns and then essentially filtering out the columns?
Hey there...love the vids. A question tho...I took a look at your implementation of "database" in your SAAS project on github and was wondering why you stored the db instance in a global variable (. (global as any).database=....) when in dev mode but not in production? What's different about dev mode that makes it a good idea to do this?
In dev mode every time you save a file it’ll create a new db connection and it ends up saturating the db connection limit
nice vid! I'm wondering what recording app you use to have rectangle video of yourself on the side
Don’t we need to order desc to the query to make sure we are getting latest 10 posts?
Yes I forgot that I think
Do you feel any speed difference between pirsma and drizzel ?
The API looks exactly like Doctrine (PHP) which looks exactly like Hibernate (Java).
Cool video :)
Which theme you are using in ur Code Editor ? that’s looking cool
A custom one, it might be made public
@@WebDevCody Do it 😎 I really wanna use in mine editor 🙏
Ummm, how did you not know how to do this in Prisma? It's been there forever
Writing raw queries in prisma isn’t the same as using a sql builder that drizzle provides.
Hey Cody, could you help me with an issue? I'm trying to set up drizzle with aws rds in postgres, but when I'm trying to push my tables, drizzle can't find my region, even though they are inside the DATABASE, SECRET_ARN and RESOURCE_ARN env variables?
I’m not too sure, did you set your database as public and allow access from your ip in your security group?
I dont know if to use drizzle or SQL somehow'?
What theme is this?
Hey cody, Nice tutorial man!!.
Wanted to ask what was the tool which allowed you to see the object structure of return beforehand?
Typescript you mean?
@@WebDevCody ohk Gotcha!
u can do this in prisma no problem
Prisma does this already 😅 I am not learning another ORM
Anyone know what keyboard he uses? It sounds sooo good.
I believe its a FunKey app for macbook
I m having a terrible time with drizzle migrations. there is no way to rollback a migration at the moment. the only way is to update/edit migration files or drop database. no one is covering these aspects of a production application.
They are currently working on a rollback for migrations. Currently the approach is to revert your scheme of file and generate another migration script and then apply it to revert the changes.
drizzle orm is one of the few javascript libraries that deserves the hype. it's actually good. unlike everything else in that ecosystem that has hype and is not very good.
Think this has been possible in prisma since day 1 no? but you can just use the regular TS stuff, dont need to use raw sql, but you can if you want I guess (edit: or is this whole video just bait to get prisma users to interact, if so, nicely done)
Writing raw queries inside a template literal doesn’t compare to using a sql builder with type safety. Maybe I’m missing something?
@@WebDevCody yeah agreed, but you wouldnt do this in a template literal, super simple with just regular prisma syntax
bring back bearded theme stained blue , i can't read
I can’t keep up with all these js frameworks
What about this , would this give the same result? :
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function getRecentPublicPostsByUserId(userId: number) {
const results = await prisma.post.findMany({
where: {
userId: userId,
Group: {
isPublic: true,
},
},
include: {
Group: true,
},
take: 10, // Limit to 10 results
orderBy: {
id: 'desc',
},
});
return results.map(result => ({
...result,
gf_posts: result
}));
}
Laravel's Eloquent
is still probably the best ORM I've used, but I might give drizzle a try. Prisma is giving me headaches...
We used sequelize in a school project and omg, oh my god how crappy the DX was I wish we used drizzle instead
I like how, contrary to Prisma, everything is still in TypeScript.
Which part of prisma isn’t available in TS?
@@rico454 In Prisma you define your schemas in a .prisma file, which is not TypeScript. While in Drizzle you do it in .ts files.
@@rod6722 oh I see what you mean
@@rod6722 I guess it comes down to personal preference tbf. The syntax in prisms schema files look way cleaner than creating a schema using TS for drizzle.
Plus you don’t actively use the schema file anyways, so as long as the rest of prisma functionality is in TS, then it’s good.
And again, it’s all personal preference
I prefer Prisma than this