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

    Austin

    07/18/2022, 9:34 AM
    Hello, I have a question: Has anyone tried to set up database transaction testing with prisma? I have a setup that only half works where I pass a function as a parameter into a function that executes
    prisma.$transaction
    , but the problem is that all subsequent queries need to be transaction-aware (and so needs to use the prisma object provided by the
    $transaction
    callback). This means I need to control the prisma object being passed to my backend functions so that instead of the normal client, they get the transaction-aware client. Is there some clever way to do this? The docs recommend mocking but I would strongly prefer transaction-rollback testing my backend functions. Any recommendations from the community? Thank you 🙏
    ✅ 1
    a
    • 2
    • 3
  • b

    Brothak

    07/18/2022, 9:39 AM
    Given schema:
    Copy code
    model User {
      id              Int       @id @default(autoincrement())
      name            String
      description    String
    }
    I would expect to be able to update User description by running:
    Copy code
    prisma.name.update({
          where: {
            name,
          },
          data: {
            description: 'Update'
          },
        });
    ✅ 1
  • b

    Brothak

    07/18/2022, 9:41 AM
    But instead I am getting typescript error Type ‘{ name: string; }’ is not assignable to type ‘UserWhereUniqueInput’ because the type only has id param:
    Copy code
    export type UserWhereUniqueInput = {
        id?: number
      }
    ✅ 1
    a
    n
    • 3
    • 3
  • k

    Kay Khan

    07/18/2022, 9:52 AM
    Having an issue with prisma on a new laptop ubuntu 22.04
    Copy code
    Error: Get Config: Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!
    Details: Unable to require(`/home/kay/checkpoint/nft-api/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node`)
     libssl.so.1.1: cannot open shared object file: No such file or directory
    
    Prisma CLI Version : 4.0.0
    Copy code
    whereis node
    node: /home/kay/.nvm/versions/node/v16.16.0/bin/node
    Copy code
    whereis openssl
    openssl: /usr/bin/openssl /home/linuxbrew/.linuxbrew/bin/openssl /usr/share/man/man1/openssl.1ssl.gz
    any ideas?
    👀 1
    n
    • 2
    • 29
  • u

    user

    07/18/2022, 10:08 AM
    👉 Sabin Adams, Aydrian Howards - Distributed data and powerful tooling with Prisma & CockroachDB --

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

    -- ◭ In this talk, you’ll learn the advantages of building reliable and scalable applications on a distributed SQL database, while guaranteeing a seamless developer experience with Prisma. We will showcase how to quickly get up and running with the forever-free CockroachDB Serverless cluster and interact with the schema and data using Prisma. ◭ Sabin Adams is a Developer Advocate at Prisma who loves spending his days playing with new tools and sharing his experiences so others can learn too. ◭ Aydrian Howard is a Hoosier living in New York City. Currently a Developer Advocate at Cockroach Labs, he enjoys mentoring at hackathons and live coding on Twitch. Aydrian began his career helping bring technology to schools by setting up computer labs and training teachers and staff. Education will always be an important aspect of his professional journey as he strives to pass on knowledge learned from personal experience and from those who’ve helped him along the way. He’s a corgi dad to Atticus and is interested in movies, theatre, attending sci-fi/comic conventions, and some light cosplay. ◭ Connect with Aydrian: https://twitter.com/itsaydrian ◭ Connect with Sabin: https://twitter.com/sabinthedev ◭ Join our Prisma Meetup group here: https://www.meetup.com/Berlin-Prisma-Meetup/
    prisma rainbow 2
    🙌 2
  • w

    windkomo

    07/18/2022, 1:53 PM
    Is there a way to modify generated queries in a middleware or something? Use case is I am using an older version of SQL Server that doesn’t support
    OFFSET x ROWS
    . I don’t need it so I just want to delete this part.
    ✅ 1
    a
    • 2
    • 2
  • m

    Maguire Krist

    07/18/2022, 4:40 PM
    My implicit many to many connections are no longer working
    👀 1
    a
    v
    • 3
    • 2
  • v

    Vanessa Kroeker

    07/18/2022, 8:01 PM
    I'm running into an issue with not being able to create new migrations (with
    prisma migrate dev
    ) after squashing migrations. Here's what I'm doing: 1. Squash migrations (following Prisma's guide on squashing migrations to create a clean history in a production environment: https://www.prisma.io/docs/guides/database/developing-with-prisma-migrate/squashing-migrations#how-to-create-a-clean-his[…]-a-production-environment), including marking the migration as applied 2. Make a change to
    schema.prisma
    3. Run
    prisma migrate dev
    to create a new migration 4. Make another change to
    schema.prisma
    5. Run
    prisma migrate dev
    to create another new migration 6. Migration fails with following error:
    Copy code
    Error: P3006
    
    Migration `20220718195944_migration_name` failed to apply cleanly to the shadow database. 
    Error code: P1014
    Error:
    The underlying table for model `users` does not exist.
    The same thing will happen if I run the first migration generation after squashing with `--create-only`: when I then subsequently try to run
    prisma migrate dev
    to apply the created migration, the same error message as above will come up. Creating/applying these migrations works fine as long as the previous migrations haven't been squashed. This is only happening after squashing. So I understand that I can revert back to the pre-squashed migration history and reset from there, but if squashing migrations is an option - and it's one we want to use - it shouldn't block further migrations from being created and applied. Any help/advice is greatly appreciated, thank you! UPDATE: This only happens when following the documented instructions for creating a clean history in a production environment, ie. by creating the
    squashed_migrations
    directory with the following command
    Copy code
    npx prisma migrate diff \
     --from-empty \
     --to-schema-datamodel ./prisma/schema.prisma \
     --script > ./prisma/migrations/squashed_migrations/migration.sql
    rather than creating it by running
    prisma migrate dev --name squashed_migrations
    .
    👀 1
    t
    • 2
    • 2
  • r

    Roryl

    07/18/2022, 10:26 PM
    Anyone know what the status of this PR is?: https://github.com/prisma/prisma-engines/pull/2451
    👀 1
    ✅ 1
    m
    • 2
    • 1
  • r

    Roryl

    07/18/2022, 10:26 PM
    Wondering why it's been sitting with two approved member reviews for... seven months?
  • r

    Roryl

    07/18/2022, 10:27 PM
    Would really love some more information about errors, it's a little painful right now to determine which of your referenced entities doesn't exist (in the case of a constraint violation) based on the current error format
    👍🏼 1
  • y

    YeonHoPark

    07/19/2022, 1:14 AM
    Hi. I know about prisma validator, but i don’t know how to use prisma validator to implement the functionality i want. Below is the approximate code of the function i want.
    getUser
    must return a value containing only information about the select object received as an argument. and it must be type safe !
    👀 1
    a
    v
    • 3
    • 5
  • t

    Tri Nguyen

    07/19/2022, 2:11 AM
    hi, anyone knows whether we can continue chaining prisma after data is fetch? For example
    Copy code
    const post = await prisma.post.findFirst({...});
    
    // continue playing with post
    post.update({...})
    ✅ 1
    n
    • 2
    • 2
  • y

    Yunbo

    07/19/2022, 3:28 AM
    How are you guys handling multiple
    .env
    ? i'd like to use
    .env.test
    .<http://env.dev|env.dev>
    .env.local
    and so on. but prisma seems like only taking
    .env
    👀 1
    ✅ 1
    a
    n
    • 3
    • 3
  • m

    Mark

    07/19/2022, 10:24 AM
    Hey guys, we are running into some performance issues with our database and digital ocean. We are using the app platform with a database that could use 97 connections but are scaling it up to 197. Would it be better to scale our pods horizontal to have more node applications with ~24 connections or scale the pods vertical so a single pod can hold up to 48 connections?
    ✅ 1
    n
    v
    • 3
    • 4
  • t

    Tom Ashford

    07/19/2022, 11:44 AM
    Hiya, I have quite few instances in my schema with 1-1 relationships between two models where I want to ensure that the creation of A requires the creation of B (so primary key is going to be on A's side, and non-nullable), but I also want to cascade delete B if A is deleted - is this possible in any way? For example if I have
    Copy code
    model User {
    	...
        profile   Profile @relation(fields: [profileID], references: [id])
        profileID Int     @unique
    }
    
    model Profile {
        ...
        user User?
    }
    I'm ensuring I can't create a User without a Profile, but that way a Profile won't get deleted if a User is deleted, right? Currently I have it the other way around so I get the cascades but then I can't require the creation of the Profile, which I'd really like to be able to do as I have a bunch of structures like this. Cheers
    ✅ 1
    • 1
    • 1
  • a

    alexwasik

    07/19/2022, 12:04 PM
    Question on how
    autoincrement
    should work. Using Cockroach DB with Prisma
    Move model
    Copy code
    model Move {
      id        BigInt   @id @default(autoincrement())
      matchId   String
    ✅ 1
    a
    • 2
    • 2
  • a

    alexwasik

    07/19/2022, 12:05 PM
    if I understand
    autoincrement
    , shouldn't the numbers be sequential?
  • a

    Arpan Bagui

    07/19/2022, 12:10 PM
    I am attaching my model, query and error screenshot. Can anyone please tell me how to resolve it?
    ✅ 1
    l
    a
    • 3
    • 14
  • k

    Katarzyna Zarnowiec

    07/19/2022, 12:51 PM
    🧵 Hello 👋 I would like to ask for status of this epic https://github.com/prisma/client-planning/issues/21 and when do you plan to work on it/having it released? I asked DataDog if they support Prisma integration, and got redirected to your issue, which seems to be blocking them currently. Could you give me some estimations on when we could expect that? Thank you 🙏
    ✅ 1
    n
    n
    • 3
    • 5
  • u

    user

    07/19/2022, 1:30 PM
    Building a REST API with NestJS and Prisma: Input Validation &amp; Transformation 8 min read Welcome to the second tutorial on the series about building a REST API with NestJS, Prisma and PostgreSQL! In this tutorial, you will learn how to perform input validation and transformation in your API.
    🔥 2
    🙌 2
  • s

    Shadee Merhi

    07/19/2022, 2:50 PM
    Hi everyone, I am currently building a chat application (using Prisma and MongoDB) that supports multi-user group chats, and I am having some trouble when trying to query for all conversations that the signed in user is a part of. The entities of interest here are
    Conversations
    ,
    ConversationParticipants
    , and
    Users
    . The relationship between
    Users
    and
    Conversations
    is many-to-many, hence the creation of the
    ConversationParticipant
    model. Here is my schema:
    Copy code
    model User {
      id             String    @id @default(auto()) @map("_id") @db.ObjectId
      name           String?
      email          String? @unique
      username       String  @unique
      messages       Message[]
      conversations  ConversationParticipants[]
      createdAt      DateTime  @default(now())
      updatedAt      DateTime  @updatedAt
    }
    
    model Conversation {
      id              String    @id @default(auto()) @map("_id") @db.ObjectId
      participants    ConversationParticipants[]
      messages        Message[]  @relation("conversationMessages")
      latestMessage   Message?   @relation(name: "latestConversationMessage", fields: [latestMessageId], references: [id], onUpdate: NoAction, onDelete: NoAction)
      latestMessageId String?    @unique
      createdAt       DateTime  @default(now())
      updatedAt       DateTime  @updatedAt
    }
    
    model ConversationParticipants {
      id              String    @id @default(auto()) @map("_id") @db.ObjectId
      conversation    Conversation @relation(fields: [conversationId], references: [id])
      conversationId  String
      user            User      @relation(fields: [userId], references: [id])
      userId          String
    }
    
    model Message {
      id              String        @id @default(auto()) @map("_id") @db.ObjectId
      conversation    Conversation  @relation(name: "conversationMessages", fields: [conversationId], references: [id])
      conversationId  String
      isLatestIn      Conversation? @relation("latestConversationMessage")
      sender          User          @relation(fields: [senderId], references: [id])
      senderId        String
      body            String
      createdAt       DateTime      @default(now())
      updatedAt       DateTime      @updatedAt
    }
    When the user signs in, I am trying to find all of the users conversations (i.e. all of the conversations where there is an existing
    ConversationParticipant
    entity). My current query is the following:
    Copy code
    // the user id comes from the session - working properly
    const { id } = session;
    
    const conversations = await prisma.conversation.findMany({
        where: {
          participants: {
            some: {
              userId: {
                equals: id,
              },
            },
          },
        },
        include: {
          participants: true,
        },
    });
    All of the similar scenarios I can find online are all using the
    some
    operator as well, so I am not sure why this isn’t working. I must be missing something 😅 Any and all help would be greatly appreciated!
    ✅ 1
    a
    • 2
    • 4
  • p

    paresh solanki

    07/19/2022, 4:52 PM
    const SingleItem =(parameter: string) =>{
  • p

    paresh solanki

    07/19/2022, 4:52 PM
    const SingleItem =(parameter: string) =>{ return ( )
  • p

    paresh solanki

    07/19/2022, 4:55 PM
    const SingleItem =(parameter: string) =>{ return ( <ListItem value = {parameter}><ListItemButton>{parameter}</ListItemButton></ListItem> )}
    ✅ 1
    n
    v
    • 3
    • 4
  • a

    Alex Okros

    07/19/2022, 5:11 PM
    Hi, has anyone ever had an issue when using
    @prisma/migrate
    with
    @prisma/internals
    as a peer dependency giving an error stating “Error: Cannot find module ‘fp-ts/TaskEither’“? I tried installing
    fp-ts
    as a peer dependency, but it doesn’t seem to be doing anything for the error.
    👀 1
    n
    • 2
    • 4
  • i

    Ivan Lukianchuk

    07/19/2022, 7:12 PM
    I've got "warn" and "error" logging setup and I'm seeing lots of unhelpful and concerning messages like this and I'm not sure what the problem is. I'm hosting my db on AWS with a db.t3.small in us-east-1 and using the Prisma Data Proxy. I don't know what the issue is or where it's coming from, any ideas?
    prisma:error Error while querying: This request must be retried
    {
    timestamp: undefined,
    message: 'Error while querying: This request must be retried',
    target: undefined
    }
    [...omitted 10x repeats of above]
    {
    timestamp: undefined,
    message: 'This request can be retried',
    target: undefined
    }
    > [...omitted 10x repeats of above]
    ✅ 1
    n
    • 2
    • 2
  • d

    Dev__

    07/20/2022, 6:55 AM
    I am trying to run a database script in my docker env but I get an error that the
    env variable
    cannot be found. this is the folder structure on the docker
    Copy code
    .env
    dist
      /scripts
        script.js
    node_modules
    prisma
      /migrations
      schema.prisma
      seed.ts
    the script files that I am running is
    script.js
    >
    node scripts.js <arg>
    it is available in the
    .env
    tho
    ✅ 1
    n
    • 2
    • 3
  • h

    Hussam Khatib

    07/20/2022, 9:08 AM
    Is there a way to include template string inside raw query
    Copy code
    prisma.$queryRaw` 
    
    // template string used in the raw sql query
     `
    ✅ 1
    n
    • 2
    • 8
  • n

    nikolasburk

    07/20/2022, 9:34 AM
    Hey Prisma friends 👋 there currently is a thread on Reddit about popular Node.js ORMs. If you’ve been enjoying Prisma, we would highly appreciate if you could share your honest experience with it in the thread and point out what you like about it as well as what issues you might have encountered 🙌
    prisma rainbow 1
    ❤️ 5
1...598599600...637Latest