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

    Jonathan Marbutt

    10/07/2022, 2:52 PM
    nvm, found it, it is the
    Prisma.dmmf.datamodels.models
  • j

    Jonathan Marbutt

    10/07/2022, 2:53 PM
    Is there a way to set the
    documentation
    property in the schema that is returned from the dmmf
    👀 1
    ✅ 1
    a
    r
    • 3
    • 5
  • j

    Jonathan Marbutt

    10/07/2022, 3:00 PM
    I think this is one thing I was also still looking for https://github.com/prisma/prisma/issues/3102
  • j

    Jonathan Marbutt

    10/07/2022, 3:00 PM
    Just the ability to add custom attributes
  • m

    Mike Willbanks

    10/07/2022, 4:32 PM
    change you are trying to make would violate the required relation - disconnect on a many-to-many relation, it’s odd and it feels like a bug to me since technically a disconnect is a
    delete
    if it is the primary key right? More details in 🧵
    ✅ 1
    n
    • 2
    • 7
  • s

    Slackbot

    10/08/2022, 4:23 AM
    This message was deleted.
  • t

    Timothy Choi

    10/08/2022, 11:46 AM
    Hi, what are good strategies to share the same piece of prisma DB operations between interactive transaction context and normal (non-transaction) context? I see https://github.com/prisma/prisma/issues/12458 but that doesn't seem to be available yet.
    ✅ 1
    n
    v
    • 3
    • 4
  • a

    Anton Wester

    10/08/2022, 11:52 AM
    Is this anything I need to worry about? Trying to bump from 3.14.0 to 4.4 using this starter. https://github.com/chamatt/create-kaol-app
    ✅ 1
    n
    • 2
    • 3
  • d

    Dibas Dauliya

    10/08/2022, 1:47 PM
    I've the tags structured as
    tags: [ { tag: { title: 'tag-1' } }, { tag: { title: 'tag-2' } } ],
    in every posts. I want to filter the post based on the tag, and I did following method but it is not returning expected posts.
    Copy code
    const data = await prisma.post.findMany({
        where: {
          tags: {
            every: {
              tag: {
                title: tagTitle,
              },
            },
          },
        },
    ...
    })
    ✅ 1
    n
    • 2
    • 2
  • a

    Anton Johansson

    10/08/2022, 1:49 PM
    Hey people! I have a TypeScript project that works with two different databases. I want to generate a Prisma model for both of them.
    npx prisma generate
    puts generated code in
    ./node_modules/.prisma/client
    . Is it possible to put the generated code in two different directories? And somehow have
    new PrismaClient();
    know which one I want to create it for?
    ✅ 1
    n
    • 2
    • 2
  • r

    Rohan Rajpal

    10/08/2022, 2:22 PM
    Is there a way to filter on length of relations? Example:
    A
    has one to many relation with
    B
    Now if I want the records in
    A
    which have less than 3 records linked to
    B
    , what will be the query in prisma? Looking to do something like this
    Copy code
    this.prisma.A.findMany({ where: { b : { count: { lt: 3 } } } })
    ✅ 1
    n
    • 2
    • 3
  • n

    N

    10/08/2022, 6:24 PM
    Question
  • n

    N

    10/08/2022, 6:24 PM
    How do you write a schema which has a growing key relationship
  • n

    N

    10/08/2022, 6:24 PM
    When you create a record it will autocreate the associated record
  • n

    N

    10/08/2022, 6:25 PM
    In the foreign key table
    ✅ 1
    n
    v
    • 3
    • 6
  • j

    Jijin P

    10/09/2022, 10:52 AM
    I have used prisma inside a docker container. and now the docker logs show this one ‘backend_app exited with code 139’ if the endpoint has some prisma-related query this error is shown. Any way to debug this one?
    ✅ 1
    n
    • 2
    • 2
  • u

    ut dev

    10/09/2022, 11:13 AM
    I have following schema:
    model Customer {
    id                 String       @id @default(cuid())
    userId             String
    companyId          String?      @unique
    salutation         String
    firstname          String
    lastname           String
    user               User         @relation(fields: [userId], references: [id], onDelete: Cascade)
    bankAccount        BankAccount?
    company            Company[]
    }
    I want to return the foreign key data aswell so I am doing this in my findMany
    getAll: t.procedure.query(({ ctx }) => {
    return ctx.prisma.customer.findMany({
    include: {
    company: true,
    bankAccount: true
    }
    });
    }),
    But I still get an error that my casing is wrong?
    next-dev.js?a272:20 TRPCClientError:
    `Invalid
    prisma.customer.findMany()
    invocation:`
    {
    include: {
    company: true,
    ~~~~~~~
    bankAccount: true,
    ~~~~~~~~~~~
    ?   projects?: true,
    ?   invoices?: true,
    ?   files?: true,
    ?   user?: true,
    ?   BankAccount?: true,
    ?   Company?: true,
    ?   _count?: true
    }
    }
    ✅ 1
    n
    v
    • 3
    • 5
  • f

    FUTC

    10/09/2022, 3:17 PM
    I’m having trouble with prisma in docker on my M1 macbook. Using the
    node:18.8.0
    image instead of an alpine image and using the node_modules folder from the host system previously solved my issues. But when I try to run our jest e2e tests I get
    Error: Unknown binaryTarget linux-arm64-openssl-undefined and no custom engine files were provided
    . It’s weird that this only happens when trying to run the e2e tests, and otherwise everything seems to work fine. Does anybody have an idea how I could fix this?
    👀 1
    n
    v
    • 3
    • 2
  • s

    Sebastian Gug

    10/09/2022, 5:55 PM
    How do you guys run migrations on a GCP cloud sql instance behind a vpc? do you SSH into a VM that can connect to the DB specifically to run migrations? it doesn't seem ideal to do it so manual, I'm sure plenty have had this problem in the past
    👀 1
    n
    v
    • 3
    • 4
  • h

    Haris Mehrzad

    10/09/2022, 11:20 PM
    Hey there I have this as part of my Prisma schema.
    Copy code
    model Starboard {
        id               String @id @default(cuid())
        guildId          String
        channelId        String
        starEmoji        String
        embedColor       String
        minimumStarCount Int
    
        messagesInStarboard MessageInStarboard[]
    
        @@unique([channelId, starEmoji])
        @@map("starboards")
    }
    
    model MessageInStarboard {
        messageId          String    @id
        authorId           String
        starboardId        String
        starboardMessageId String
        starboard          Starboard @relation(fields: [starboardId], references: [id], onDelete: Cascade)
    
        userStarsOnMessage UserStarOnMessage[]
    
        @@map("messages_in_starboard")
    }
    
    model UserStarOnMessage {
        emoji            String
        userId           String
        authorId         String
        guildId          String
        channelId        String
        messageId        String
        starboardId      String
        starredMessageId String?
    
        starboardMessage MessageInStarboard? @relation(fields: [starredMessageId], references: [messageId], onDelete: Cascade)
    
        @@id([messageId, userId])
        @@map("stars_on_messages")
    }
    However, when I try to run an
    updateMany()
    seen below.
    Copy code
    this.client.prisma.userStarOnMessage.updateMany(
                                        {
                                            where: {
                                                messageId: fetchedMessaged.id,
                                                starredMessageId: null
                                            },
                                            data: {
                                                starredMessageId:
                                                    messageAlreadyStarred.starboardMessageId
                                            }
                                        }
                                    )
    I get the following error.
    Copy code
    PrismaClientKnownRequestError: 
    Invalid `prisma.userStarOnMessage.updateMany()` invocation:
    
    
      Foreign key constraint failed on the field: `stars_on_messages_starredMessageId_fkey (index)`
        at RequestHandler.request (/Users/polar/Projects/starboard/node_modules/.pnpm/@prisma+client@3.15.2_prisma@3.15.2/node_modules/@prisma/client/runtime/index.js:49022:15)
        at async PrismaClient._request (/Users/polar/Projects/starboard/node_modules/.pnpm/@prisma+client@3.15.2_prisma@3.15.2/node_modules/@prisma/client/runtime/index.js:49919:18)
        at async Promise.all (index 0)
        at async Promise.all (index 0)
        at async MessageReactionAdd._run (file:///Users/polar/Projects/starboard/dist/lib/classes/EventHandler.js:30:20) {
      code: 'P2003',
      clientVersion: '3.15.2',
      meta: { field_name: 'stars_on_messages_starredMessageId_fkey (index)' }
    }
    👀 1
    n
    v
    • 3
    • 2
  • f

    Faizan

    10/10/2022, 8:43 AM
    I am facing this issue on Prisma
    Copy code
    Error: Failed to convert napi `string` into rust type `String`
    With the following prisma versions
    Copy code
    "dependencies": {
      "@prisma/client": "^3.15.2",
      "prisma": "3.15.2"
    }
    What is weird is that the exact code works on a teammate's system.
    ✅ 1
    j
    • 2
    • 4
  • n

    Nurul

    10/10/2022, 10:09 AM
    https://prisma.slack.com/archives/C044YLSN49E/p1665396575376719?thread_ts=1665393022.428069&cid=C044YLSN49E
    👀 1
    s
    • 2
    • 1
  • f

    Firat Özcan

    10/10/2022, 11:08 AM
    Hey, is there currently a way of passing in a
    where
    argument in a include for a one-to-one relation? I am having this query and for access control I want to add a where clause but it's not typed and I guess this also means that it wont be executed if I just add it there
    Copy code
    prisma.invoiceLine.findMany({
        include: {
          Track: {
            where: accessibleBy(user).Track, // This is what I need but it doesnt exist
            select: {
              Name: true
            }
          }
        }
      })
    👀 1
    a
    • 2
    • 5
  • f

    Firat Özcan

    10/10/2022, 11:08 AM
    The
    invoiceLine
    has a one-to-one relation to Track
  • f

    Firat Özcan

    10/10/2022, 11:10 AM
    Is there a workaround towards somehow getting a where clause into this include?
  • n

    Nurul

    10/11/2022, 7:40 AM
    https://prisma.slack.com/archives/CA491RJH0/p1665473968469019?thread_ts=1665416912.727229&cid=CA491RJH0
  • r

    Raimond Lume

    10/10/2022, 12:45 PM
    Hey! 👋 I’m having a peculiar issue: the
    RelationFilter
    type loses the
    null
    option for a model after a seemingly unrelated schema update. What I changed in the schema: I added a new m-to-m model, which references the table
    Solution
    . Nothing changed in the model for the
    Solution
    itself. I’ve attached screenshots of the type before (1st screenshot) and after (2nd screenshot) Why did the type change? For context, I was using
    isNot: null
    to filter on null relations before, which stopped working suddenly - that’s where I discovered the type issue Using client v4.4.0, TS v4.83
    ✅ 1
    a
    • 2
    • 4
  • r

    Rinil Kunhiraman

    10/10/2022, 2:04 PM
    https://www.prisma.io/docs/guides/testing/unit-testing#example-unit-tests. Anyone here followed this guide with nestjs for testing?
    👀 1
    ✅ 1
    a
    • 2
    • 4
  • r

    Reo Yamashita

    10/10/2022, 2:11 PM
    Hi ! To get count data with findMany API, we have to also use count API?
    👀 1
    a
    v
    • 3
    • 7
  • j

    jt

    10/10/2022, 3:26 PM
    Anybody know how to import data using the raw import api in prisma v1? I was able to use a cURL command to get the exported data in json format, but I'm running into issues importing the data into my local copy of the project with the exact same schema
    👀 1
    n
    v
    • 3
    • 3
1...630631632...637Latest