This is why I love drizzle ORM

Поделиться
HTML-код
  • Опубликовано: 9 янв 2025

Комментарии • 82

  • @trebturner
    @trebturner 6 месяцев назад +39

    Love the shorter and more specific videos!

  • @lucasfranzolin
    @lucasfranzolin 6 месяцев назад +13

    srtaight to the point!! I'm loving the path this channel has taken, good stuff bro!!

  • @h4nto772
    @h4nto772 6 месяцев назад +86

    no matter how fast we are, your wife will always be first

  • @chikin6358
    @chikin6358 6 месяцев назад +22

    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

    • @joaquimley
      @joaquimley 6 месяцев назад +2

      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.

    • @sathishkannan6600
      @sathishkannan6600 Месяц назад

      Exactly what I wanted to say.

  • @thimodev
    @thimodev 6 месяцев назад +2

    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

    • @BenMargolius
      @BenMargolius 6 месяцев назад

      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.

    • @azizsafudin
      @azizsafudin 6 месяцев назад

      @@BenMargoliusit’s not a trivial amount at scale

  • @my_yt666
    @my_yt666 6 месяцев назад +12

    Prisma support this easily without a sweat. Where it lacks a bit are advanced usages of aggregates.

    • @WebDevCody
      @WebDevCody  6 месяцев назад +3

      Thanks for letting me know

  • @SeibertSwirl
    @SeibertSwirl 6 месяцев назад +81

    Good job babe!!!! First yeaaaaaa 👸🏽

    • @WebDevCody
      @WebDevCody  6 месяцев назад +29

      Thanks my number one!

    • @stanleychukwu7424
      @stanleychukwu7424 6 месяцев назад +13

      i swear, i never new you were his wife.. Good for you guys, i'm getting married next year too, i can't wait

    • @damjandjordjevic1994
      @damjandjordjevic1994 6 месяцев назад +5

      @@stanleychukwu7424 She literally comments on every single one of his videos. Pretty cool 😎

    • @Alex1611AD
      @Alex1611AD 4 месяца назад +1

      This is so wholesome

  • @kashnigahbaruda
    @kashnigahbaruda 6 месяцев назад +8

    Prisma has been able to do that for years. In a much simpler way (imo) too.

  • @maelstrom7144
    @maelstrom7144 6 месяцев назад +5

    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!

  • @kaansal9523
    @kaansal9523 6 месяцев назад

    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!

  • @Prince_515
    @Prince_515 6 месяцев назад +3

    What keyboard are you using? It sounds really nice

  • @nicolasramos7084
    @nicolasramos7084 6 месяцев назад

    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

  • @fottymutunda6320
    @fottymutunda6320 6 месяцев назад +1

    I'd love to see the actual generated query

  • @loorinho
    @loorinho 6 месяцев назад +2

    Much love as always from Uganda "mentor"...

  • @TaohidKhan-ut6gf
    @TaohidKhan-ut6gf 6 месяцев назад

    Make a crash course on complex sql query using drizzle ORM. Love to see your contents

  • @simonhylander7489
    @simonhylander7489 3 месяца назад

    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

  • @MirkoVukusic
    @MirkoVukusic 6 месяцев назад +1

    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

  • @codingwithjamal
    @codingwithjamal 6 месяцев назад

    I just started using drizzle and turso for my new project and it makes using sqlite so much better in typescript

  • @Fiercesoulking
    @Fiercesoulking 6 месяцев назад

    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

  • @jon1867
    @jon1867 Месяц назад

    prisma definitely supports this

  • @Consignion
    @Consignion 6 месяцев назад

    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?

  • @DaveMacpherson
    @DaveMacpherson 5 месяцев назад

    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?

    • @WebDevCody
      @WebDevCody  5 месяцев назад +1

      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

  • @giandenorte
    @giandenorte 6 месяцев назад

    nice vid! I'm wondering what recording app you use to have rectangle video of yourself on the side

  • @DhanushkaC
    @DhanushkaC 6 месяцев назад +2

    Don’t we need to order desc to the query to make sure we are getting latest 10 posts?

    • @WebDevCody
      @WebDevCody  6 месяцев назад +1

      Yes I forgot that I think

  • @kumardeepanshu8503
    @kumardeepanshu8503 6 месяцев назад

    Do you feel any speed difference between pirsma and drizzel ?

  • @DaviMartins99
    @DaviMartins99 6 месяцев назад

    The API looks exactly like Doctrine (PHP) which looks exactly like Hibernate (Java).
    Cool video :)

  • @Zero-nh4ke
    @Zero-nh4ke 6 месяцев назад +1

    Which theme you are using in ur Code Editor ? that’s looking cool

    • @WebDevCody
      @WebDevCody  6 месяцев назад +2

      A custom one, it might be made public

    • @Zero-nh4ke
      @Zero-nh4ke 6 месяцев назад +1

      @@WebDevCody Do it 😎 I really wanna use in mine editor 🙏

  • @FranFiori94
    @FranFiori94 6 месяцев назад +1

    Ummm, how did you not know how to do this in Prisma? It's been there forever

    • @WebDevCody
      @WebDevCody  6 месяцев назад +1

      Writing raw queries in prisma isn’t the same as using a sql builder that drizzle provides.

  • @jens-mikaelstjernberg1037
    @jens-mikaelstjernberg1037 6 месяцев назад

    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?

    • @WebDevCody
      @WebDevCody  6 месяцев назад

      I’m not too sure, did you set your database as public and allow access from your ip in your security group?

  • @rolandmurru6568
    @rolandmurru6568 6 месяцев назад

    I dont know if to use drizzle or SQL somehow'?

  • @pixelsbyme
    @pixelsbyme 5 месяцев назад

    What theme is this?

  • @AdityaRaj-lj5wf
    @AdityaRaj-lj5wf 6 месяцев назад

    Hey cody, Nice tutorial man!!.
    Wanted to ask what was the tool which allowed you to see the object structure of return beforehand?

  • @reversetcp
    @reversetcp 6 месяцев назад +1

    u can do this in prisma no problem

  • @peterluke9392
    @peterluke9392 6 месяцев назад

    Prisma does this already 😅 I am not learning another ORM

  • @deepjyotideb1173
    @deepjyotideb1173 6 месяцев назад

    Anyone know what keyboard he uses? It sounds sooo good.

    • @shockgalaxy9849
      @shockgalaxy9849 6 месяцев назад

      I believe its a FunKey app for macbook

  • @hannad
    @hannad 5 месяцев назад

    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.

    • @WebDevCody
      @WebDevCody  5 месяцев назад

      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.

  • @crab-cake
    @crab-cake 6 месяцев назад

    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.

  • @jackjsy
    @jackjsy 6 месяцев назад

    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)

    • @WebDevCody
      @WebDevCody  6 месяцев назад

      Writing raw queries inside a template literal doesn’t compare to using a sql builder with type safety. Maybe I’m missing something?

    • @jackjsy
      @jackjsy 6 месяцев назад +1

      @@WebDevCody yeah agreed, but you wouldnt do this in a template literal, super simple with just regular prisma syntax

  • @kisaki345
    @kisaki345 6 месяцев назад

    bring back bearded theme stained blue , i can't read

  • @brunomorales9200
    @brunomorales9200 6 месяцев назад +1

    I can’t keep up with all these js frameworks

  • @ardianhotii
    @ardianhotii 6 месяцев назад +2

    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
    }));
    }

  • @jovincebrillantes1042
    @jovincebrillantes1042 6 месяцев назад +1

    Laravel's Eloquent
    is still probably the best ORM I've used, but I might give drizzle a try. Prisma is giving me headaches...

  • @yassine-sa
    @yassine-sa 6 месяцев назад

    We used sequelize in a school project and omg, oh my god how crappy the DX was I wish we used drizzle instead

  • @rod6722
    @rod6722 6 месяцев назад +1

    I like how, contrary to Prisma, everything is still in TypeScript.

    • @rico454
      @rico454 6 месяцев назад

      Which part of prisma isn’t available in TS?

    • @rod6722
      @rod6722 6 месяцев назад +1

      @@rico454 In Prisma you define your schemas in a .prisma file, which is not TypeScript. While in Drizzle you do it in .ts files.

    • @rico454
      @rico454 6 месяцев назад

      @@rod6722 oh I see what you mean

    • @rico454
      @rico454 6 месяцев назад +1

      @@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

  • @crazycode2578
    @crazycode2578 6 месяцев назад +1

    I prefer Prisma than this