Drizzle ORM in Nest.JS

Поділитися
Вставка
  • Опубліковано 8 вер 2024
  • ❤️Please Support me by subscribing to my channel 👉🏻www.youtube.co...
    In this video we are going to integrate the Nest.JS with Drizzle ORM.

КОМЕНТАРІ • 27

  • @theofiloschamalis161
    @theofiloschamalis161 5 місяців тому +6

    Thanks for the video, it was really useful for helping set up drizzle with the postgres-js driver!
    The only things that I did differently were:
    1. Importing from 'drizzle-orm/postgres-js' for the type of the db variable in the constructor of the service that I am injecting it.
    2. Importing from 'drizzle-orm/pg-core' and using these definitions for the schema.ts file.
    3. Exporting form the schema.ts file the types like so: export type UserAdded = typeof user.$inferInsert;
    4. Inside the drizzle.config.ts file I have used dotenv to import my env variables like so:
    import { config } from 'dotenv';
    config({ path: `.env.${process.env.NODE_ENV}` });
    and created an npm script like so:
    "migrations:push": "cross-env NODE_ENV=development npx drizzle-kit push:pg"
    similarly created one to generate migrations and one to drop them.
    Hope this helps anyone looking to set this up with postgres-js !

    • @ThanhLe-bs4nu
      @ThanhLe-bs4nu 2 місяці тому

      Do you have the repo for the postgres database setup ?
      could you share it to me please ? appreciate it

  • @VladdyHell
    @VladdyHell 11 місяців тому +4

    I used ChatGPT to generate this timestamps so it might not be accurate:
    0:00 - Introduction and overview of the video.
    1:05 - Removing the Prisma client and dependencies.
    1:52 - Installing Drizzle ORM and SQLite3 driver.
    2:22 - Creating the schema.ts file for Drizzle ORM.
    3:12 - Defining the "users" table in the schema.ts file.
    5:32 - Deleting the Prisma directory.
    5:52 - Creating the Drizzle provider for the Nest.js application.
    9:11 - Refactoring the "create" function in the user service.
    13:00 - Refactoring the "findByEmail" function in the user service.
    15:36 - Refactoring the "findById" function in the user service.
    16:54 - Registering the Drizzle provider in the user module.
    18:38 - Running migrations to create the SQLite database.
    20:56 - Testing the application with Insomnia.
    22:27 - Recapping the key steps and achievements in the video.

    • @SakuraDev
      @SakuraDev  11 місяців тому

      Hi, Thanks 🙏. Is it chatGPT 4 ?

  • @mohit84604
    @mohit84604 11 місяців тому +2

    Thank you sir. This is the only video for which i was waiting

    • @SakuraDev
      @SakuraDev  11 місяців тому +1

      👋, Yes it's finally there. Thanks for your patience 🙏👍

  • @emirefek
    @emirefek 7 місяців тому +1

    Was waiting for tests with drizzle. How you mock it for jest?

  • @jasonrooney1368
    @jasonrooney1368 10 місяців тому +2

    You’re recreating a database connection for every module. You shouldn’t be adding drizzeProviders to your users and auto modules. You should be importing the Drizzle module instead.

    • @archip8021
      @archip8021 8 місяців тому

      could you elaborate on this?

    • @g-luu
      @g-luu 6 місяців тому

      i was looking for this comment, people shouldn’t be doing this

  • @belkocik
    @belkocik 3 місяці тому

    What about postgres?

    • @SakuraDev
      @SakuraDev  2 місяці тому +1

      I am creating a comprehensive course that involves postgres.

  • @eliotfagnon7319
    @eliotfagnon7319 5 місяців тому

    The vscode theme is too beautiful, which one is it?

    • @SakuraDev
      @SakuraDev  5 місяців тому

      Hi, it's bearded theme

  • @_codesan
    @_codesan 11 місяців тому +1

    Please create video about saml 😢

    • @SakuraDev
      @SakuraDev  11 місяців тому +1

      Hi 👋, I need to do some research about it.

  • @asadmehboob1300
    @asadmehboob1300 11 місяців тому

    Nice video...please also implement repository pattern in Nestjs with drizzle and swagger

  • @jijivre
    @jijivre 11 місяців тому

    What should you put in the dizzle provider file if you want to use postgre instead of sqlite?

  • @anowarulhassan5117
    @anowarulhassan5117 11 місяців тому

    hello, I got stucked to implement google adsense to my newly released nextjs 13.4(App Router) project. I tried most of the tutorials which I found on google search and youtube search and didnot found any solutions to implement google adsense. I tried many npm packages also but they didnot worked for me also. Please make a video on how we can implement google adsense on Nextjs 13.4(app router) without losing SSR.

  • @parmetra
    @parmetra 10 місяців тому

    Hello! Could you help me, please?
    At 9:31 I get an error.
    @Module({
    providers: [...drizzleProvider],
    })
    the provider is highlighted as an error. I have provided the error text below. what is it and how can I fix it?
    Type '{ provider: string; useFactory: () => Promise; exports: string[]; }[]' is not assignable to type 'Provider[]'.
    Type '{ provider: string; useFactory: () => Promise; exports: string[]; }' is not assignable to type 'Provider'.
    Property 'provide' is missing in type '{ provider: string; useFactory: () => Promise; exports: string[]; }' but required in type 'FactoryProvider'.ts(2322)

  • @zlatkoiliev8927
    @zlatkoiliev8927 4 місяці тому

    This is waaay too complicated. I would've just stick with prisma if I had to start a new project...

    • @SakuraDev
      @SakuraDev  4 місяці тому

      Prisma is really straightforward but in performance, Drizzle ORM comes first 🥇

    • @SakuraDev
      @SakuraDev  4 місяці тому

      Prisma is really straightforward but in performance, Drizzle ORM comes first 🥇