https://www.prisma.io/ logo
Join SlackCommunities
Powered by
# orm-help
  • g

    gustav

    09/20/2021, 6:09 PM
    in a graphql resolver
    r
    • 2
    • 2
  • c

    Chris Tsongas

    09/20/2021, 7:15 PM
    How does everyone like using implicit many-to-many relations instead of defining them explicitly in your
    prisma.schema
    ? The docs give a good comparison for how implicit m-n relations simplify queries, and of course if a relation table needs to store additional fields I would define it explicitly, but are implicit relations generally recommended?
  • c

    Chris Tsongas

    09/20/2021, 7:25 PM
    I just tried adding a many-to-many self relation and noticed the relation defaulted to
    ON DELETE CASCADE ON UPDATE CASCADE
    which seems strange given that relations now default to disallow? Maybe that's just to delete the relation if one of the related items gets deleted?
  • c

    Chris Packett

    09/20/2021, 10:59 PM
    Copy code
    Step 0 Added the required column `companyId` to the `Subscription` table without a default value.
    what’s the best way around this?
  • c

    Chris Packett

    09/20/2021, 11:01 PM
    Do I need to add a @default(0) if it is of type
    Int
    ? Or is there something else I can do?
    r
    • 2
    • 2
  • m

    Markey Boi

    09/21/2021, 12:46 AM
    Hello! I'm currently transitioning my codebase from TypeORM to Prisma and was wondering if anyone here could help figure out how this TypeORM query would look in Prisma. (Skip and take are commented out because they were causing errors, part of the reason we decided to switch away from TypeORM). Edit: moved code to snippet
  • m

    Markey Boi

    09/21/2021, 12:53 AM
    Untitled.ts
    r
    • 2
    • 7
  • a

    Anmol Jawandha

    09/21/2021, 6:45 AM
    Hi, Is there a way to filter records based on a latest relation in prisma? For example, I have USERs with related POSTs, and I want to get all users whose latest post has title 'XYZ'. Thanks!
    • 1
    • 1
  • d

    Damien Duhamel

    09/21/2021, 7:56 AM
    Hi guys, since I migrated to version 3.x.x, when I generate a migration Prisma add a lot of index renaming absolutely not related to the changes I did in my schema. More over when I tried to apply the migration generated, it throws an error indicating the renamed index doesn’t exist. Any idea of the issue ?
    d
    • 2
    • 13
  • u

    user

    09/21/2021, 9:25 AM
    What's new in Prisma (v3.1.0)

    https://www.youtube.com/watch?v=nLHJCzWxS5M▾

    Daniel and Matt from the Prisma team discuss the latest 3.0.1 release of Prisma and other news from the Prisma ecosystem. Tune in to learn about new releases, how to upgrade, planned features, and other interesting bits from the Prisma world. ------------------------ 📚 Resources: ✅ Subscribe to Prisma: https://www.youtube.com/channel/UCptA... ✅ Get help from the Prisma Community: https://slack.prisma.io/ ✅ Learn more about Prisma: ◭ Website: https://www.prisma.io ◭ Docs: https://www.prisma.io/docs ◭ Quickstart: https://pris.ly/qstart ------------------------ 💬 Connect with Prisma: Twitter: https://twitter.com/prisma Instagram: https://www.instagram.com/prisma.io/ TikTok: https://www.tiktok.com/@prismadata Facebook: https://www.facebook.com/prisma.io LinkedIn: https://www.linkedin.com/company/pris... ------------------------ Prisma sponsors human-reviewed, professional closed captions for ANY video valuable to our community (for example, about: Node.js, TypeScript & Type Safety, Prisma, databases, etc). Get your FREE captions here: https://pris.ly/closedcaptions
  • b

    Bård

    09/21/2021, 10:00 AM
    Hey! Have a question regarding using _count in a .findMany-query I was under the impression I could count fields in a findMany query query:
    Copy code
    const result = await prisma.profile.findMany({
      distinct: ['schoolKey', 'sex'],
      where: {
        user: {
          emailVerified: {
            not: null,
          },
        },
      },
    
      select: {
        _count: {
          sex: true
        },
      },
    });
    I'm getting the error: Unknown field
    _count
    for select statement on model Profile.
    r
    b
    • 3
    • 2
  • a

    Albin Groen

    09/21/2021, 11:09 AM
    Hi, I have a use case for Prisma that I'm not sure you support. I have a model like this
    Copy code
    model Task {
      id          String  @id @default(uuid())
      completed   Boolean @default(false)
      title       String
      companyId   String
    }
    In this case I would like to the companyId field to reference a company model. The thing is though, companies doesn't live in the task database. Also, the model doesn't live in this service either. How would I go about solving this?
    r
    • 2
    • 4
  • h

    Harsha MV

    09/21/2021, 11:27 AM
    hey.. anyone here has created a many to many relationship?
  • h

    Harsha MV

    09/21/2021, 11:27 AM
    with custom table name?
  • h

    Harsha MV

    09/21/2021, 11:29 AM
    am getting this error
  • h

    Harsha MV

    09/21/2021, 11:29 AM
    Copy code
    model ProjectCategories {
      project       Project  @relation(fields: [projectId], references: [id])
      projectId  String // relation scalar field (used in the `@relation` attribute above)
      category   Category @relation(fields: [categoryId], references: [id])
      categoryId String // relation scalar field (used in the `@relation` attribute above)
    
    
      @@id([projectId, categoryId])
    }
    r
    • 2
    • 12
  • h

    Harsha MV

    09/21/2021, 11:31 AM
    Copy code
    model Project {
      id                          String    @id @unique @default(uuid()) @db.Uuid
      name                        String    @db.VarChar(255)
      catgories      ProjectCategories[]
    }
  • h

    Harsha MV

    09/21/2021, 11:32 AM
    Copy code
    model Category {
      id         String              @id @unique @default(uuid()) @db.Uuid
      name       String              @db.VarChar(255)
      projects   ProjectCategories[]
    
    }
  • s

    Salah eddine Ait Balkacem

    09/21/2021, 12:19 PM
    hey, can createMany be used with many to many tables? I have a company table with employees like in the screenshot, I want to insert a company and it's employees(bulk), is there a way to achieve this in similar way to createMany?
  • h

    Harsha MV

    09/21/2021, 12:25 PM
    yes
  • h

    Harsha MV

    09/21/2021, 12:25 PM
    Copy code
    categories: {
                            create: [
                                {
                                    category: {
                                        connect: {
                                            id: categoriesArr[randomCategory],
                                        },
                                    },
                                },
                            ],
                        },
  • h

    Harsha MV

    09/21/2021, 12:26 PM
    use that category array n supply an array of employee objects
    ✅ 1
  • h

    Harsha MV

    09/21/2021, 12:26 PM
    @Salah eddine Ait Balkacem
  • s

    Salah eddine Ait Balkacem

    09/21/2021, 12:28 PM
    @Harsha MV Thanks I'll try that
  • d

    Damien Duhamel

    09/21/2021, 1:13 PM
    Hi, I have the exact same case that this stackoverflow question about LEFT JOINS and aggregation. Can you confirm this is the right answer ? Impossible to do it with a single query ? How does it scale ?
    r
    • 2
    • 2
  • u

    user

    09/21/2021, 3:32 PM
    Prisma Meetup #8

    https://www.youtube.com/watch?v=PMp_yi91sR8▾

    Prisma Online Meetup #8 is coming up! 🤓 Join us on the 28th of September, 6 PM CEST. 🌍 Join engineers from all around the globe to learn about database best practices, the Prisma inside scoop, and examples of Prisma in production.
  • m

    Matt Langer

    09/21/2021, 6:21 PM
    short question: did 3.0.2 happen to change any connection retry logic? (longer context in thread 👇 )
    • 1
    • 1
  • m

    Mo El

    09/21/2021, 6:44 PM
    This issue is gaining popularity, any idea if it’s on the roadmap? https://github.com/prisma/prisma/issues/2505#issuecomment-924012542
    r
    • 2
    • 3
  • h

    Harsha MV

    09/21/2021, 7:03 PM
    Am getting this error when I try to do
    prisma migrate reset
    Copy code
    DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42601"), message: "syntax error at or near \"yarn\"", detail: None, hint: None, position: Some(Original(1)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("scan.l"), line: Some(1176), routine: Some("scanner_yyerror") }
    r
    • 2
    • 8
  • h

    Harsha MV

    09/21/2021, 7:03 PM
    how to recover from it?
1...485486487...637Latest