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

    Callum

    02/16/2022, 7:57 AM
    Hey guys, I want to run route tests with express and prisma. I wanted to setup a dev database for the test data, however I'm a little stumped, how do I run a migration in code (so that the database gets set up once jest runs) also is this a good idea? i'm open to better ideas
    Untitled.js
  • c

    Coditoiu Mihai

    02/16/2022, 8:55 AM
    Hi Guys, I have this error
    Query createOneEvent is required to return data, but found no record(s)
    after about 10 inserts into db and then I have to restart the server. I am using prisma 2(3.9.2) with MySql. Does anybody knows what can be the problem? The error occurrs only on Heroku, on may local machine is working well
    w
    • 2
    • 3
  • u

    user

    02/16/2022, 10:13 AM
    What's new in Prisma (v3.10.0)

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

    Austin and Alex from the Prisma team discuss the latest 3.10.0 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.
    🙌🏻 1
  • u

    user

    02/16/2022, 10:15 AM
    What's new in Prisma (v3.11.0)

    https://www.youtube.com/watch?v=2dAtmHuT-30▾

    Austin and Alex from the Prisma team discuss the latest 3.11.0 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.
    🙌🏻 1
    🙌 1
  • t

    Tomáš Průha

    02/16/2022, 1:07 PM
    Hello everybody. I am in need of help with designing prisma schema. I created question on stackoverflow but community there is very new and small, so i got no responses. I would be really greatful if you could help me with it. https://stackoverflow.com/questions/71071504/prisma-schema-one-to-many-realtions-from-multiple-tables-to-one
  • k

    Kelly Copley

    02/16/2022, 1:39 PM
    Bumping this as I can't seem go figure it out.
    • 1
    • 2
  • o

    Omar Khairy

    02/16/2022, 5:26 PM
    can you use 'connect' in a nested 'createMany' when writing with Prisma Client?
    n
    • 2
    • 2
  • j

    Juan Gabriel Palarpalar

    02/16/2022, 5:39 PM
    Hello. I have three tables. Preferences, Clients, and clientPreferences. The relation is many-to-many.
    Copy code
    Preferences {
      id
      ...
    }
    
    Clients {
      id
      ...
    }
    
    clientPreferences {
      id
      clientId
      preferenceId
    }
    Now, a preference can be attached/detached to multiple clients. My question is how will I update existing record in
    clientPreferences
    and at the same time, add a record if it doesn’t exist? My HTTP endpoint for this is
    PATCH /preferences/:id
    with the JSON request body of
    Copy code
    {
      "clientIds": [
        1,
        2,
        3
      ]
    }
  • j

    Juan Gabriel Palarpalar

    02/16/2022, 5:39 PM
    Thank you!
  • j

    John McElreavey

    02/16/2022, 6:48 PM
    Hey, is is possible to say where a joined table has a column of this state or is undefined:
    Copy code
    where: {
        outcome: {
          OR: [
            {
              state: undefined,
            },
            {
              state: MatchOutcomeState.POSITION_ACCEPTED,
            },
            {
              state: MatchOutcomeState.POSITION_UNDER_OFFER,
            },
          ],
        },
    }
    Basically I want all records where there is no outcome record or if there is I want it in a specific state.
  • k

    Kelly Copley

    02/16/2022, 7:09 PM
    So as far as I can figure out, this has something to do with the sql_mode being set to only_full_group_by. I'm using planetscale and it literally only happens on my development branch.. If I connect to my main branch it works fine. 🙄
  • k

    Kelly Copley

    02/16/2022, 7:12 PM
    Does anyone have any experience with this and could point me in the right direction.. I'm in a deadlock on moving this project forward.
    d
    • 2
    • 2
  • s

    Sam Lambert

    02/16/2022, 7:28 PM
    @Kelly Copley support@planetscale.com will be able to help you
  • k

    Kelly Copley

    02/16/2022, 7:32 PM
    @Sam Lambert Yeah, unfortunately no reply for hours now.
  • s

    Shmuel

    02/16/2022, 7:55 PM
    Hi. Does prisma support conditional clauses in a
    where
    block, similar to laravel's
    when()
    function. https://laravel.com/docs/8.x/queries#conditional-clauses
    n
    • 2
    • 2
  • m

    Michael Aubry

    02/16/2022, 11:28 PM
    I chose Prisma because its awesome. Someone mentioned Firebase and I am looking (out of curiosity) the pros and cons between the two of them. Does anyone here have some insight?
    👀 1
    n
    • 2
    • 3
  • j

    Jonathan Marbutt

    02/17/2022, 3:06 AM
    Are most people using prisma migrate for managing schema changes and outside db features? Or are you using products like flyway or something else? We have the need for a good bit of stored procedure management and a few other things that might be pushing what we should do in prisma.
    n
    • 2
    • 8
  • k

    khareta

    02/17/2022, 8:17 AM
    Has query random been implemented yet? it's been a long time already. It would really speed up our website, since we currently use workarounds with query raw
    s
    • 2
    • 1
  • k

    Kay Khan

    02/17/2022, 9:50 AM
    I have a question when trying to define types after receiving data from prisma with includes. I have an authentication table where i am joining 2 other tables (user and authentication_permission). I then map over the data and create my final object, you can see in the first code block it is complaining that authentication_permission and user does not exist on authentication type. In the second code block i found a work around to that, im just wondering if there is a nicer way? a nicer way for me would be to only have to use a single type. I could not find anything in the prisma/client generated code which had something like
    Copy code
    export type authentication_with_all_includes {
      ...
      user: user,
      authentication_permission: authentication_permission[]
    }
  • s

    sagar lama

    02/17/2022, 10:44 AM
    I have a User model and a DegreeLevel model. And I've Linked the two with many to many. when I query with prisma client, instead of getting the degree level, I get the data of the many to many table. Is that the intenal return value? With typeorm I used to get the related models. How do I get the actual related model?
    Copy code
    model User {
    ...
      degree_levels UserDegreeLevels[]
    }
    
    model DegreeLevel {
    
    ...
    users User[]
    }
    
    model UserDegreeLevels {
      id           Int          @id @default(autoincrement())
      degree_level DegreeLevel @relation(fields: [degreeId], references: [id], onDelete: Cascade)
      degreeId     Int
      user         User         @relation(fields: [userId], references: [id], onDelete: Cascade)
      userId       Int
      created_at   DateTime     @default(now())
      updated_at   DateTime     @updatedAt
    }
    When i execute the following query,
    Copy code
    const user = await this.prismaService.user.findFirst({
          where: { id },
          include: {
            degree_levels: true,
          },
        });
    I get
    Copy code
    {
       id: 5,
       ...
       degree_levels: [
         {
           id: 1,
           uuid: '1cca9b39-af0b-4219-a951-93f205fab67f',
           degreeId: 10,
           userId: 5,
           created_at: 2022-02-17T09:00:52.024Z,
           updated_at: 2022-02-17T09:00:52.025Z
         },
         {
           id: 2,
           uuid: '709ee342-e6d5-4e49-8d23-6339cf0fb0d6',
           degreeId: 11,
           userId: 5,
           created_at: 2022-02-17T09:00:52.024Z,
           updated_at: 2022-02-17T09:00:52.025Z
         }
       ]
     }
    The result I want
    Copy code
    {
       id: 5,
       ...
       degree_levels: [
         DegreeLevel1, # values of degree level model
         DegreeLevel2
        
       ]
     }
  • e

    Elijah Rosier

    02/17/2022, 10:45 AM
    Anyone know if there's a way to mock the DateTimes in an integration test when they're set by
    @default(now())
    ? We running jest tests against the database and want to ensure the correct dates are being inserted, and don't want brittle tests.
  • m

    Manu Rodgers

    02/17/2022, 11:17 AM
    What's the difference between uuid and cuid?
    n
    • 2
    • 1
  • g

    Geebrox

    02/17/2022, 12:11 PM
    Is there any ways to divide schemas into separate files where I describe only model? e.g. I have main schema with
    datasource
    and
    generator
    configs and other files where I describe only `model`s. My schema file becomes to large and it is hard to maintain everything in one file
    n
    • 2
    • 2
  • b

    ben

    02/17/2022, 5:07 PM
    I can't for the life of me get Prisma to create a DB, using
    Copy code
    await prismaClient.$executeRaw(
      Prisma.sql`CREATE DATABASE ${databaseId} TEMPLATE ${templateName};`
    );
    on postgres, getting
    STATEMENT:  CREATE DATABASE $1 TEMPLATE $2;
    through on the DB side
    t
    n
    • 3
    • 4
  • g

    Gabriele Palmiotto

    02/17/2022, 7:40 PM
    Can somebody help me? https://github.com/prisma/prisma/discussions/11888 Thanks
    👍 1
  • j

    Joshua Ramin

    02/18/2022, 7:13 AM
    does anyone know how to use file upload with useState hook in react? cuz I'm still getting an error. The file uploading API is working using GraphQL Altair btw
  • s

    sagar lama

    02/18/2022, 7:18 AM
    How to return value for many to many relation,
    Copy code
    model Post {
      id         Int                 @id @default(autoincrement())
      title      String
      categories CategoriesOnPosts[]
    }
    
    model Category {
      id    Int                 @id @default(autoincrement())
      name  String
      posts CategoriesOnPosts[]
    }
    
    model CategoriesOnPosts {
      post       Post     @relation(fields: [postId], references: [id])
      postId     Int
      category   Category @relation(fields: [categoryId], references: [id])
      categoryId Int
      assignedAt DateTime @default(now())
      assignedBy String
    
      @@id([postId, categoryId])
    }
    Typescript is giving me an error when I try the following,
    Copy code
    jest.spyOn(<http://prisma.post|prisma.post>, 'findFirst').mockResolvedValue({
        ...mockPost,
        categories: [...mockCategories],
    });
  • e

    Eko Nur Arifin

    02/18/2022, 9:26 AM
    hi guys, any idea we make flexible or condition with if like this? for now i got last condition.. thanks a lot all 🙏
    e
    • 2
    • 2
  • s

    Sreenivas Dunna

    02/18/2022, 12:20 PM
    Hi team, I want to add createdby and updatedby automatically from session variable for auditing purpose. can someone please help me to how can I achieve with the prisma and nestjs?
    • 1
    • 1
  • o

    Onkel Tem

    02/18/2022, 12:38 PM
    Hi folks! I'm learning Prisma now, need some help
1...546547548...637Latest