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

    Halvor

    08/14/2021, 9:20 AM
    Copy code
    Like prisma.statGamemodeDM.aggregate() vs prisma.statGamemodeTDM.aggregate({
    r
    • 2
    • 1
  • j

    Jitesh Dhamaniya

    08/14/2021, 10:36 AM
    trying to connect to postgres but it keeps failing
  • j

    Jitesh Dhamaniya

    08/14/2021, 10:38 AM
    connection is working, I am to connect to it using db client, so no problem at db end. any thoughts. ?
    r
    j
    • 3
    • 2
  • k

    khareta

    08/14/2021, 12:21 PM
    Is it safe to use named constraints now? (I know it's under preview flag)
    r
    • 2
    • 1
  • f

    Flor Ronsmans De Vry

    08/14/2021, 1:39 PM
    Does anyone know what the following error means? I’m pretty clueless here as there’s not much information in the error message
    Copy code
    WARN
      Invalid `prisma.licenseType.create()` invocation:
    
      Null constraint violation on the fields: ()
    
      Invalid `prisma.licenseType.create()` invocation:
      Null constraint violation on the fields: ()
    ✅ 1
    • 1
    • 1
  • r

    Rykuno

    08/14/2021, 11:47 PM
    Interactive transactions are throwing this type error in typescript, anyone familiar with it?
    r
    b
    • 3
    • 2
  • r

    Rykuno

    08/15/2021, 12:04 AM
    And another question. Is there a rollback implementation that is supported outside of transactions? For example for each user added, it also needs to update Algolia. If either fail, both fail or the prisma operation is rolled back.
    r
    • 2
    • 1
  • h

    Halvor

    08/15/2021, 11:35 AM
    I it possible to use javascript filter lists with prisma?
    r
    • 2
    • 1
  • s

    stephan levi

    08/15/2021, 1:23 PM
    i need the prisma docker file plz in order to run prisma inside DOCKER
    r
    • 2
    • 1
  • o

    Omar Ghanim

    08/16/2021, 4:21 AM
    hi , prisma return this error , although i updated prisma and prisma client to latest version , the second problem is interactive transactions are showing error in typescript <say should return type of (PrimsaPromise<any>[])> thanks
    r
    • 2
    • 4
  • u

    user

    08/16/2021, 10:23 AM
    How to use Named Constraints with Prisma

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

    ◭ Version 2.29.0 Release notes: https://github.com/prisma/prisma/releases/tag/2.29.0 Prisma's 2.29.0 release includes support for Named Constraints. This is super useful for custom constraints that do not match conventional naming. In this video, Jon Meyers walks through introspecting an existing remote PostgreSQL Database, and creating a locally hosted development environment. ◭ Named Constraints docs: https://www.prisma.io/docs/guides/upgrade-guides/upgrading-to-use-preview-features/enabling-named-constraints Learn more about Prisma: ◭ Website: https://www.prisma.io​​​ ◭ Docs: https://www.prisma.io/docs​​​ ◭ Quickstart: https://www.prisma.io/docs/getting-started/quickstart-typescript
  • d

    danielvanc

    08/16/2021, 10:33 AM
    Bit of a long shot and appreciate this might be more to do with KeyStoneJS, but i wondered if anyone who has used KeyStoneJS with Prisma and NextAuth, might know the problem i’ve run into…. So i’m running a nextJs project, and KeystoneJS, when running the dev server, it updates the prisma schema file. Problem i’ve run into, is that it’s difficult to generate a schema the same as what’s outlined in the ‘Setup’ portion of this page: https://next-auth.js.org/adapters/prisma What I would ideally need to know is how to generate this line from KeyStoneJS: “@@unique([providerId, providerAccountId])”
    • 1
    • 1
  • p

    per

    08/16/2021, 10:38 AM
    Hey peeps! Started using Prisma and really enjoying it so far! I have a question regarding optional columns: Let’s say I want to make a query for a team. A team always have a player1 but player2 is optional. How do I query this in prisma? This code will break if only player1 is present on a team. Thanks and yes, I am a big noob 😄
    Untitled.js
    r
    • 2
    • 51
  • s

    Slackbot

    08/16/2021, 10:49 AM
    This message was deleted.
    r
    d
    • 3
    • 2
  • b

    Bård

    08/16/2021, 11:24 AM
    Anyone know why I'm getting a unique constraint fail on "taskID" when trying to create a new entry on the "Tasks" model?
    Copy code
    model Task {
      id          String    @id @default(cuid())
      title       String
      description String
      location    Location?
      quiz        Quiz[]
      tasks       Tasks?
    }
    
    model Tasks {
      id       Int    @id @default(autoincrement())
      sequence Int
      lat      Float?
      lng      Float?
      distance Float?
      quiz     Int?
      seedID   String
      taskID   String
      task     Task   @relation(fields: [taskID], references: [id])
      seed     Seed   @relation(fields: [seedID], references: [id])
    }
    Unique constraint failed on the fields: (
    taskID
    )
    r
    • 2
    • 3
  • k

    kkangsan

    08/16/2021, 12:22 PM
    Unique constraint failed on the fields: (
    id
    ) ERROR T^T... Do you know how to reset pk?..
    Copy code
    await prisma.user.deleteMany()
    console.log(await prisma.user.findMany()); // []
    await prisma.user.create({
          data: {
            id: '123',
          },
        });   // Error
    r
    • 2
    • 9
  • d

    Dan Shapir

    08/16/2021, 12:31 PM
    Hey, regarding the interactiveTransactions new amazing feature. In the release notes it states that you can control isolation level and locking for now, which is OK, but what is the current locking then? If I do to actions in the same transaction. Let’s say an aggregation on a table and then a query on the same table, can some other transaction insert or change data between my to reads?
    r
    • 2
    • 6
  • g

    Gelo

    08/16/2021, 2:32 PM
    How to get the type of "where" property?
  • g

    Gelo

    08/16/2021, 2:42 PM
    When using AND operator this happens
    r
    • 2
    • 5
  • v

    Vladi Stevanovic

    08/16/2021, 3:31 PM
    ✨ Prisma is sponsoring this year's @TypeScriptConf ! ✨ Watch out for the after conference entertainment - we have a fun surprise in store! 😉 🗓️ Friday, Sept 10th, 2021 🎟️ Get your ticket here: https://ti.to/SitePen-Consulting/tsconf-2021
    prisma cool 7
    fast parrot 9
    💯 6
    ❤️ 6
  • k

    kkangsan

    08/17/2021, 1:37 AM
    sample_ts.ts
  • k

    kkangsan

    08/17/2021, 1:38 AM
    Perhaps in the jest test, create query behaves lazy. (Is my guess right? ??) Can you tell me how to solve it?
    r
    • 2
    • 3
  • v

    Venu

    08/17/2021, 4:53 AM
    hey folks, i need some help with the NestJs code first approach. I am starting to learn and implement Prisma2. I want to understand how do we generate the prisma schema? I see that schema.gql gets generated automatically. @ryan Could you please help me on this? I
    m
    • 2
    • 14
  • d

    Dev__

    08/17/2021, 9:31 AM
    does
    prisma
    do a
    toFixed
    underwater when inserting a value to a
    Decimal
    field type?
  • b

    Bård

    08/17/2021, 10:09 AM
    Based on this schema:
    Copy code
    model Seed {
      id        String   @id @default(cuid())
      uid       String
      score     Int?
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
      user      User     @relation(fields: [uid], references: [id])
      tasks     Tasks[]
    }
    I want to query to create a highscore list based on the score value. But I also want to find the users relation to that highscore. Say that the users score is number 400 in the highscore list. Is there any way to query the model and sort by score, then count the amount of entries up to the first entry that contains the user?
    r
    • 2
    • 5
  • d

    Dean Valentine

    08/17/2021, 10:44 AM
    Hi; trying to do some performance optimizations. Right now I return a giant session object for every lookup for convenience's sake. Information that's not included in that object is queried afterwards, in sequential db hits. To make things a little bit more performant, I'm building a type safe function that just pulls the required information to verify the users' cookies _and also whatever select the caller adds_:
    Copy code
    function resolveSession(cookies: Cookies, select: Prisma.SessionSelect) {
         const session = await prisma.findUnique(where {...}, select: merge(select, {id: xxx, token: yyy, ...}), 
         ...verify session integrity
         return session
    }
    r
    • 2
    • 2
  • d

    Dean Valentine

    08/17/2021, 10:46 AM
    However, no matter how I seem to formulate this, I can't seem to get type safety working. The best I've gotten is for the function to return an object with the session information but lacking the prisma session select stuff.
  • d

    Dean Valentine

    08/17/2021, 10:49 AM
    Right now I'm just going to make two queries in the same transaction, but I'd like to just make one...
  • s

    stephan levi

    08/17/2021, 12:41 PM
    when creating multi hierarchy with prisma is there a way to have a touch point like the netsted inner objects in GET operations ? on the one hand i want to be able to create a hierarchical object with one operation on the other hand i want to add BL to the insertion of each and every inner object
    r
    • 2
    • 2
  • t

    Tom

    08/17/2021, 1:31 PM
    Hi, I want to reset the my prisma postgres database before each test suite in cypress. I’m using this command:
    cy.exec(‘npm run db:reset’)
    which runs this script:
    Copy code
    echo “DROP DATABASE foodplanet WITH (FORCE); CREATE DATABASE foodplanet;” | sudo docker exec -i foodplanet psql -U postgres
    cat prisma/backup/development_data.sql | sudo docker exec -i foodplanet psql -U postgres foodplanet
    However, sometimes I get the error:
    Copy code
    PrismaClientKnownRequestError3 [PrismaClientKnownRequestError]:
    Invalid `prisma.nutrient.findMany()` invocation:
      Server has closed the connection.
    I think it is because the webapp is doing an API request in the same moment as the reset command gets executed. Does anybody know how to stop all current requests or the whole webapp during the execution of the command? The problem is that the cypress test fails because of the 500 server error. Is there another way to reset the whole database between test suits? (I don’t want to use prisma seed because it is too slow)
1...470471472...637Latest