Learn Prisma Relationships (1-1, 1-m, m-m)

Поділитися
Вставка
  • Опубліковано 25 гру 2024

КОМЕНТАРІ • 27

  • @ThiagoVieira91
    @ThiagoVieira91 2 роки тому +3

    A bright side of being a night lurker on Brazil: having the opportunity to watch awesome tutorials on Aussie afternoon. Superb tutorial again Tom. 👌🏼

  • @gosnooky
    @gosnooky Рік тому +2

    I notice you do a lot of dev migrations (around 26:00). I'd recommend using prisma db push to apply changes to the database while in dev and only creating a migration once satisfied everything works as intended. This keeps the migrations history leaner, as it only has major schema changes, no minor ones. Think of it in git terms, you make a lot of commits as you work, then you push or merge once those changes are finalized.
    Note: I know this is done for demonstration purposes, it's just a tip for viewers.

  • @yunhanhuang9304
    @yunhanhuang9304 2 роки тому +2

    Such an amazing and clear tutorial! 🤩

  • @1ststandardcbse908
    @1ststandardcbse908 2 роки тому +2

    Thank you so much.... Verymuch needed..... I really mean it... Thank you very much

  • @pablom8854
    @pablom8854 Рік тому +1

    Thanks for the video! It was just a bit too fast but I'll analyze it with more time

  • @snivels
    @snivels Рік тому

    You do incredible work! Love you stuff, especially the more advanced stuff

  • @notko8431
    @notko8431 2 роки тому +2

    absolute legend you are

  • @abdullah-ayy
    @abdullah-ayy Рік тому +1

    The many-to-many relation at 13:01 between product and Category doesn't make sense.
    The one that is defined is one-to-many, not many-to-many
    I am assuming you will change that later on in the video.

  • @williamcao5139
    @williamcao5139 2 роки тому +2

    Awesome, thanks for your efforts

  • @WhhhhhhjuuuuuH
    @WhhhhhhjuuuuuH 2 роки тому +2

    This is very very very useful

  • @muhammadashfaq913
    @muhammadashfaq913 Рік тому +1

    @TomDoesTech What is the VSCode extension you are using that is giving your Prisma Syntax Suggestion? That's really cool bro

  • @Grishopping
    @Grishopping Рік тому

    waooo I really liked your video, will you have any video using prism where you compare tables or products ... example I have several stores that sell the same products that can compare the prices of those products and organize them in order from cheapest to most expensive ... examples in that style ...??
    or you could guide me how to do it ... greetings Jose Grillo of Venezuela

  • @notfadeaway6617
    @notfadeaway6617 Рік тому +1

    thank you

  • @muhammedubeyd
    @muhammedubeyd Рік тому

    Thank you very much for your effort, Does Prisma has model inheritance like BaseEntity implementation, if it has, how can we make it with Postgres, if not, is there any promise in the future to make it in Prisma?

  • @allisfehr
    @allisfehr 2 роки тому

    @19.29, you're mapping your product category to a random category that was already made in the first transaction. If you were seeding a database with an array of users with an array of tasks, do you know how you'd map a the first element of the items array to the first user in the user array? ie. userid: task[task.map((i, index) => index)].id.....I'm getting Type 'number[]' cannot be used as an index type.ts(2538).

    • @TomDoesTech
      @TomDoesTech  2 роки тому

      Map returns an array, so you're trying to get the id prop from an array. You'd need to do task[task.map((i, index) => index)[0]].id

    • @allisfehr
      @allisfehr 2 роки тому

      ​@@TomDoesTech I re-did some of my stuff exactly how you used the index at 24:16 and my errors went away. Unfortunately I'm getting a weird type error now. Have you seen anything like: (property) taskId: { connect: { id: string | undefined; }; } Type '{ connect: { id: string | undefined; }; }' is not assignable to type 'string'.ts(2322)
      My schema is:
      model List {
      id String @id @default(cuid())
      name String @unique
      tasks ListTask[]
      materials Materials[]
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
      }
      model ListTask {
      id String @id @default(cuid())
      taskName String
      taskDescription String
      list List @relation(fields: [listId], references: [id])
      listId String
      }
      My query is:
      const list = await createList();
      //^^ this part creates 10 lists via a transaction in a different file and returns the data
      const task = await prisma.$transaction(
      Array(10)
      .fill(null)
      .map((_, i) => {
      return prisma.task.create({
      data: {
      taskName: "Some name"
      taskDescription: "some description"
      listId: {

    • @allisfehr
      @allisfehr 2 роки тому

      Fixed my own issue. I just had to query list instead of listId

  • @dearvivekkumar
    @dearvivekkumar 2 роки тому

    let's suppose we have a user table and multiple profile tables (CustomerProfile, Admin profile)
    in this case different profiles tables have one relation userID.
    How are you going to tackle the User table ?
    do we need to add multiple fields in users table like CustomerProfile? ,AdminProfile

    • @proletar3799
      @proletar3799 2 роки тому

      lets how the Polymorphic relationships or BelongTo works on ur case.. (but idk ,it will solve ur case or not with prisma. as i heard in a year ago, prisma doesnt supp it yet ).
      i cant elaborate them in details, but i believe i had a same case as urs in the prev proj.

    • @TomDoesTech
      @TomDoesTech  2 роки тому

      Yeah, you could either have a reference on the user for each profile. Or, have a `userProfile` which has all the shared data, then have a reference to each of the distinct tables.
      To be honest, I'm not 100% why you'd want to do this so there might be a nicer solution.

  • @changNoi1337
    @changNoi1337 Рік тому

    great tutorial, next time deactivate the autocomplete?

  • @SergiyAntonyuk_PhD
    @SergiyAntonyuk_PhD Рік тому

    Very poor explanation, designed for trained users who have already worked with Prisma.

    • @TomDoesTech
      @TomDoesTech  Рік тому

      Yes. If you haven't used Prisma you're better off starting with a beginners guide or their docs

  • @musa.ibrahim.80
    @musa.ibrahim.80 Рік тому +1

    what are you teaching man? you're not explaining anything. nobody is here to see you coding, we are here to understand stuffs.

  • @виртуоз_ру
    @виртуоз_ру 11 місяців тому

    Хорош 👍