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

    Daniel Sieradski

    07/16/2021, 3:37 PM
    Hi, I have a quick question about updating records sequentially. Let's say I have a record that's related to another record as a child record of a parent record. How do I get the ID of the parent to feed into the child relationally in a single query?
    r
    • 2
    • 13
  • g

    glekner

    07/16/2021, 8:05 PM
    can you embed Prisma Studio inside a web app?
    m
    • 2
    • 2
  • d

    Douglas

    07/16/2021, 9:20 PM
    Where is the best place to get help / advice for developing with Prisma? I have a question regarding how to set up my model in my schema.
    m
    c
    +2
    • 5
    • 13
  • m

    Mo El

    07/16/2021, 10:07 PM
    Curious how folks have been using the fluent API to find one record instead of list
  • m

    Mo El

    07/17/2021, 12:59 AM
    Thoughts on authorization frameworks that work with Prisma? I recently stumbled upon this: https://github.com/stalniy/casl which does have authorization for Prisma https://github.com/stalniy/casl/tree/master/packages/casl-prisma
  • k

    khareta

    07/17/2021, 3:33 AM
    Should the initial migration for an existing schema be different than the output of a mysqldump? mysqldump:
    Copy code
    PRIMARY KEY (`id`),
      UNIQUE KEY `id_UNIQUE` (`id`),
      UNIQUE KEY `locationId` (`locationId`),
      KEY `userId` (`userId`),
    
      CONSTRAINT `Item_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `User` (`id`),
      CONSTRAINT `Item_ibfk_2` FOREIGN KEY (`locationId`) REFERENCES `Location` (`id`)
    prisma migrate:
    Copy code
    PRIMARY KEY (`id`)  
      UNIQUE INDEX `Item.locationId_unique`(`locationId`),
      INDEX `userId`(`userId`),
    
      ALTER TABLE `Item` ADD FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
      ALTER TABLE `Item` ADD FOREIGN KEY (`locationId`) REFERENCES `Location`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
    From above you should see that migrate got two things wrong:
    Copy code
    1- missing: 
    UNIQUE KEY `id_UNIQUE` (`id`)
    
    2- wrong name, should have been `locationId`
    UNIQUE INDEX `Item.locationId_unique`(`locationId`)
    I checked the generated migration line by line. All tables are missing
    UNIQUE KEY id_UNIQUE (id)
    , in addition to some tables having inconsistent index/key names; sometimes it's prepended by the table name, others isn't. Also, would using these newly generated prisma index names cause any problems on production? (when base-lining for example) Should I accept the initial migration and apply it as is, then run and edit a second migration to rename these indexes and missing constraints?
  • m

    Michael Dausmann

    07/17/2021, 7:02 AM
    I am using Prisma with Postgres. I need to use $queryRaw due to use of unsupported tsvector types. In this query, I also need to use an 'in' statement where the items in the 'in' list need to be parameterised.. I have tried this
    const ids = [41, 55]
    `const result = await prisma.$queryRaw`select * from users where id in (${ids})`;` but I get a kernel panic
    PANIC in /root/.cargo/git/checkouts/rust-postgres-dc0fca9be721a90f/8a61d46/postgres-types/src/lib.rs:762:18
    expected array type
    any Idea how I can achieve this?
    • 1
    • 4
  • l

    Logan Lee

    07/17/2021, 7:28 AM
    createMany’s data doesn’t specify type eventhough popup show the type
    r
    • 2
    • 5
  • l

    Logan Lee

    07/17/2021, 7:29 AM
    i’ve done remove schema and generate again then reload vscode but it still specify as any
  • m

    Michael Dausmann

    07/17/2021, 7:36 AM
    are the functions from sql-template-tag e.g. the join method, re-exported by Prisma?
    l
    r
    • 3
    • 17
  • m

    Mischa

    07/17/2021, 12:38 PM
    I'm working on trying to create a CDK lambda layer construct that contains the prisma engine and generated client. The idea is if you have more than one function it'll factor out those dependencies and the client generation to a layer so they can be shared amonst your functions. I posted about my progress and implementation here if anyone's interested
    🔥 1
  • m

    Mischa

    07/17/2021, 12:38 PM
  • d

    Douglas

    07/17/2021, 1:24 PM
    Does anyone know how to basically factory reset everything as if it's the first time prisma is setting up? I'm having some troubles with migrations and would just like to start over since I'm only prototyping.
    a
    r
    • 3
    • 2
  • j

    joao.santos

    07/17/2021, 2:07 PM
    Hi guys, can someone help me with this? https://prisma.slack.com/archives/CA491RJH0/p1625899614379100
  • k

    khareta

    07/17/2021, 4:44 PM
    I could be doing something wrong, but why is generated migration implements the opposite of what I want to achieve? I changed
    BusinessLocation.userId_unique
    to
    userId_UNIQUE
    , but received this:
    Copy code
    ALTER TABLE `BusinessLocation` RENAME INDEX `userId_UNIQUE` TO `BusinessLocation.userId_unique`;
    Please note that the initial migration was
    create-only
    and this is the second one, also
    create-only
    . nothing applied yet to db.
    r
    • 2
    • 4
  • d

    Dan Shapir

    07/17/2021, 8:20 PM
    How do you create a history table in prisma? The equivalent is using triggers, each time there is an update, you save the current copy in the history table. But how can this be done in Prisma as there are no triggers?
    👀 1
    a
    r
    • 3
    • 2
  • k

    khareta

    07/18/2021, 9:00 AM
    Has anybody here used mysqldump output as the initial migration and it actually worked?
  • j

    Jason

    07/19/2021, 1:58 AM
    is
    prisma introspect
    supposed to pull
    @default
    attributes too? I ran the script and it seems that the attribute was dropped. Not sure why. Version 2.27 on postgres. Is anyone else experiencing this?
    r
    • 2
    • 1
  • f

    Feralheart

    07/19/2021, 9:51 AM
    I have an
    user
    model where
    user.name
    and
    user.email
    are both unique (
    @@unique([name, email])
    ) and when I want to upsert with these two properties I got the following error:
    Type '{ name: string; email: string; }' is not assignable to type 'UsersWhereUniqueInput'.
    d
    • 2
    • 2
  • l

    Luca Nigido

    07/19/2021, 10:14 AM
    Hello guys, I have a nested structure of section > page > block and I would like to avoid a nested response from prisma to avoid a nested loop in the client that is very slow. I would like to get from prisma 3 arrays like this [section] [page] [block] and I will handle a way to combine in the right order with one loop (or in any case not 3) 🙂
    r
    • 2
    • 6
  • l

    Luca Nigido

    07/19/2021, 10:20 AM
    anyone knows if and how to get a raw query response?
  • g

    Giuseppe

    07/19/2021, 11:05 AM
    I have a self relation and when I try to count things I get this error: https://stackoverflow.com/questions/68432776/count-self-relation-on-prisma-error-table-name-specified-more-than-once I'd appreciate any help
    👀 1
    d
    • 2
    • 1
  • d

    Dustin

    07/19/2021, 3:46 PM
    Hey guys, When using pgbouncer, do we also need to pass in the
    connection_limit
    parameter along with
    pgbouncer=true
    ? Im asking this because im still getting errors saying
    Timed out fetching a new connection from the connection pool.
    when my pgbouncer instances say they have 11 used_clients and 39 free_clients still.
    • 1
    • 1
  • s

    Slackbot

    07/19/2021, 4:04 PM
    This message was deleted.
    a
    • 2
    • 1
  • h

    Hei

    07/19/2021, 4:46 PM
    Hi, any idea/resources on how to run a
    prisma migrate deploy
    in a docker-compose?
    r
    • 2
    • 1
  • c

    Cameron Johnson

    07/19/2021, 5:09 PM
    Is there a way to get insight into any running or blocked queries? My app has scheduled jobs that query with Prisma and it crashes after a few hours, I want to check and see if any of those jobs are keeping connections open since eventually Prisma throws a
    Timed out fetching a new connection from the connection pool.
    After throwing this error once it stops making queries for good until restarted. I’m sure it’s a bug in my code but don’t know how to get insight into why those existing connections aren’t getting cleaned up.
  • a

    Andrew Obrigewitsch

    07/19/2021, 5:27 PM
    Hello, I'm trying to solve a problem related to Mongo: We want access to an object that exists on a mongo DB document is this possible?
  • j

    João Hortale

    07/19/2021, 5:44 PM
    hi there, is there any channel focussed in Next.js?
    🙌 3
    r
    • 2
    • 1
  • g

    Gelo

    07/20/2021, 6:29 AM
    Date query is hard
  • g

    Gelo

    07/20/2021, 6:29 AM
    Does storing Date only is not possible yet?
    r
    • 2
    • 4
1...460461462...637Latest