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

    Oleg Yarin

    11/14/2021, 5:10 PM
    Hi there! I am asking again with regard to the query performance. When using
    prisma.create
    :
    Copy code
    await this.prisma.statement.create({
          data: {
            contextId,
            content: statementData.content,
          },
        });
    It seems that prisma sends two SQL queries to database:
    Copy code
    prisma:query INSERT INTO "public"."Statement" ("content","contextId","createdAt") VALUES ($1,$2,$3) RETURNING "public"."Statement"."id"
    
    prisma:query SELECT "public"."Statement"."id", "public"."Statement"."content", "public"."Statement"."contextId", "public"."Statement"."createdAt" FROM "public"."Statement" WHERE "public"."Statement"."id" = $1 LIMIT $2 OFFSET $3
    Is there a way to exclude sending a second query in this scenario?
    r
    • 2
    • 3
  • o

    Oleg Yarin

    11/14/2021, 5:14 PM
    Another question when using the
    .update
    function of the client API I am trying to update a record with provided id:
    Copy code
    const updateStatement = await this.prisma.statement.update({
          where: { id },
          data: {
            content: statementData.content,
          },
        });
    Prisma client in such a case sends three sql queries to databse
    Copy code
    prisma:query SELECT "public"."Statement"."id" FROM "public"."Statement" WHERE "public"."Statement"."id" = $1
    prisma:query UPDATE "public"."Statement" SET "content" = $1 WHERE "public"."Statement"."id" IN ($2)
    prisma:query SELECT "public"."Statement"."id", "public"."Statement"."content", "public"."Statement"."contextId", "public"."Statement"."createdAt" FROM "public"."Statement" WHERE "public"."Statement"."id" = $1 LIMIT $2 OFFSET $3
    I see it correctly, the first query does not make sense. Could you confirm that this is the case?
  • j

    Jin

    11/14/2021, 5:57 PM
    Hello everyone. Can somebody help me why this Dockerfile cannot recognise the command “yarn production” ? [[PM2][ERROR] Script not found: /app/production
    r
    • 2
    • 11
  • j

    James Pickard

    11/15/2021, 12:20 PM
    When I run
    npx prisma db pull
    it is using a plural for a one-to-many foreign key (e.g. I have a key called
    control_id
    but it generates a field on the model called
    controls
    - not
    control
    ) is that a bug?
    r
    • 2
    • 2
  • j

    Jordansz

    11/15/2021, 12:25 PM
    hello everyone im all out of sudden get a
    Copy code
    Argument id: Got invalid value 'ckvxz34bl0000074mhkz1y27g' on prisma.findManyMembership. Provided String, expected IntFilter or Int:
    error
    r
    • 2
    • 24
  • j

    Jordansz

    11/15/2021, 12:25 PM
    i did not modify the database columns, what would be best way to debug this?
  • j

    Jordansz

    11/15/2021, 12:28 PM
    it seems that whatever id i provide even if its integer it stil thinks its a string so /members/1 also fails
  • r

    Riccardo Nigrelli

    11/15/2021, 2:09 PM
    Hi everyone! I looking for the best way to handle the
    update
    error when the entity with a specific
    id
    doesn't exist. For example, I wrote this function to update one entry of a specific table:
    Copy code
    updateEntity(_: Subscribed, id: number, data: Prisma.UtilityTypeUpdateInput): Promise<DAORes<UtilityType>>;
    updateEntity(_: Subscribed, id: number, ref: Number): Promise<DAORes<UtilityType>>;
    async updateEntity(_: Subscribed, id: any, param: any): Promise<DAORes<UtilityType>> {
      try {
        if (typeof param !== 'object') throw new Error('Param type not supported');
          
        const entity = await this.prisma.utilityType.update({ where: { id: id }, data: param });
        return { status: 'UPDATED', entity };
      }
      catch (err) {
        process.env.DEBUG === '1' && console.log(`[ERR]: ${err}`);
        return { status: 'INTERNAL_ERROR', messageKey: 'ErrorUpdateResource' };
      }
    }
    If
    id
    doesn't exist in the table the error is correctly catched. Is there a way to had more granularity to the error since the
    err
    hasn't any code error?
  • k

    Kristofer Pervin

    11/15/2021, 3:51 PM
    Hoping to put this out again: I was wondering if anyone knows of a good way to replicate this package or this implementation with NextJS, MySQL, and Prisma? Would Prisma be willing to expand on the Seed feature to allow for this kind of migration?
    👀 1
    n
    t
    • 3
    • 2
  • l

    ldlework

    11/15/2021, 5:50 PM
    Does anyone know anything about Prisma's plans to continue their effort to provide a code-first schema?
    u
    r
    • 3
    • 5
  • u

    user

    11/15/2021, 6:10 PM
    How Elsevier Piloted an Innovative Publication Process Quickly and Flexibly with Prisma Elsevier is a global leader in information and analytics in scientific publishing and helps researchers and healthcare professionals advance science and improve health outcomes for the benefit of society. With the help of Prisma, Elsevier is in the process of modernizing the scientific publishing process efficiently and with flexibility.
  • l

    Lars Ivar Igesund

    11/15/2021, 6:13 PM
    I suggest reading the Wikipedia article about Elsevier before gloryfying them too much. Probably the most hated organization in academia.
  • j

    Josef Henryson

    11/15/2021, 8:02 PM
    ok, suddenly I feel very stupid… (again) I am about to launch my migrated code that runs Prisma 3 to our stage environment. But I realize I can’t find any config for the DATABASE_URL, not in my env vars or in any .env file. May it be that it uses 127.0.0.1:3306 per default for provider mysql? At which stage does it read the env variable? Is it with prisma genrate? Or later in generated prisma client?
    r
    • 2
    • 13
  • j

    Joonatan

    11/15/2021, 9:01 PM
    Hi! If anyone has any ideas to my problem, I would be happy to receive some help https://github.com/prisma/prisma/discussions/10278
  • a

    Anderson da Silva

    11/15/2021, 9:12 PM
    Does anyone know if there are any plans to have prisma for Deno? I saw an old thread on github but there were no news after a while
    r
    t
    • 3
    • 2
  • a

    Ahmet

    11/16/2021, 12:56 AM
    How can I define json specific key index in schema?
    r
    • 2
    • 1
  • a

    Antoin Campbell

    11/16/2021, 2:08 AM
    hey everyone, I have two models and its a 1-1 relation:
    Copy code
    model User {
      id                  String                @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
      firstName           String?
      lastName            String?
      email               String?               @unique
      profile             Profile?
      role                UserRole              @default(USER)
      createdAt           DateTime              @default(now())
      updatedAt           DateTime              @updatedAt
    
      @@index([id, email])
    }
    
    model Profile {
      id          String   @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
      user        User     @relation(fields: [userId], references: [id])
      userId      String   @db.Uuid
      displayName String?  @unique
      biography   String?
      createdAt   DateTime @default(now())
      updatedAt   DateTime @updatedAt
    }
    im trying to access
    user.profile
    and it is telling me that the property profile does not exist on the model user. im having trouble understanding why this isnt possible or the right way to do this
    r
    • 2
    • 4
  • a

    Antoin Campbell

    11/16/2021, 2:12 AM
    I guess this way of accessing related attributes is not supported and I need to use the
    user['profile']
    notation? I just want to double check
  • a

    Awey

    11/16/2021, 6:47 AM
    Is there a way to set constraints on a model? Given the following model
    Copy code
    model Follows {
      createdAt   DateTime @default(now())
      follower    User     @relation("follower", fields: [followerId], references: [id])
      followerId  Int
      following   User     @relation("following", fields: [followingId], references: [id])
      followingId Int
    
      @@id([followerId, followingId])
    }
    I want make sure followerId and followingId can never be the same.
    r
    • 2
    • 5
  • f

    febreeze

    11/16/2021, 9:52 AM
    hey guys, couldn’t find any good information on this. Is it possible to split the schema in separate files? I assume it’s not planned since the formatting etc. only works with the main schema file.
    s
    b
    • 3
    • 5
  • u

    user

    11/16/2021, 10:45 AM
    What's new in Prisma (v3.5.0)

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

    Daniel and Niko from the Prisma team discuss the latest 3.3.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.
  • m

    Michael Anderjaska

    11/16/2021, 11:33 AM
    Hey all! Looking forward to the talks. I signed up because a coworker said we need to move off of server-less because of connection pooling issues 🙄, so I need to prevent that from happening.
    🙌 2
    🙌🏽 1
  • u

    user

    11/16/2021, 12:06 PM
    GitHub Africa/GraphQL Berlin Meetup + a raffle! 🎁

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

    Join us on November 29, 5 PM CET, for this very special edition of GraphQL Berlin Meetup, where we join forces with the GitHub Africa Meetup group! 💪 Connect with GraphQL enthusiasts worldwide, get inspired by the talks, and join the Q&A session. During this meetup, we will host a raffle, where you can win a copy of the "Designing Data-Intensive Applications" by Martin Kleppmann. 🎁 Our superstar lineup: 🎙️ Alex Ruheni (@ruheni_alex) - "Type-safe GraphQL APIs with Prisma and Nexus" 🎙️ Eli Perkins (@_eliperkins) - TBA 🎙️ Kudakwashe Mupeni (https://2wce.github.io/) - "E2E Testing for GraphQL API using Prisma, Docker & Jest"
  • o

    Octavio Augusto Barbosa

    11/16/2021, 2:29 PM
    Hi! I need a little help with the prisma, I have some microservices that need to access the PrismaClient, how can I export the configurations, models and methods so that I can access them?
    r
    • 2
    • 4
  • j

    Jonas

    11/16/2021, 3:36 PM
    Hey! Is a Prisma Rust Client planned?
    r
    • 2
    • 1
  • j

    Joshua Reilly

    11/16/2021, 3:40 PM
    Can anyone see what might be wrong with my connection url? It works fine with
    prisma db pull
    but does not work with
    prisma migrate dev
    . Is this a bug?
    Copy code
    Error: P1012: error: Error validating: This line is not a valid definition within a datasource.
      -->  schema.prisma:4
       | 
     3 |                 provider = "sqlserver"
     4 |                 url = "<sqlserver://goblin>\dev:1434;database=stats;integratedSecurity=true;trustServerCertificate=true;"
     5 |             }
       |
    r
    • 2
    • 1
  • g

    Garrick Chippendale

    11/16/2021, 4:11 PM
    I was trying out the new
    Order by relevance in full text search (PostgreSQL)
    , and maybe im misunderstanding it, but im having an issue:
    Copy code
    const cards = await prisma.card.findMany({
        include: {
            character: true,
            creator: true
        },
        where: {
            character: {
                name: {
                    contains: value,
                    mode: 'insensitive'
                }
            },
            user_id: member.user.id
        },
        take: 10,
        // Here <-------------
        orderBy: {
            _relevance: {
                fields: [{ character: ['name'] }],
                search: value,
                sort: 'desc'
            }
        }
    });
    this definitely fails, because i just made up/guessed the syntax for
    fields
    , but the only 2 fields i can input are the unique fields, which are just the IDs that arent useful at all for search/ordering/etc. it only lets me put
    user_id
    and
    creator_id
    as the fields, but i would expect i can sort by the
    character.name
    which is the important string that the user is searching for.
    r
    • 2
    • 3
  • u

    user

    11/16/2021, 4:19 PM
    Prisma Serverless Conference 2021

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

    Join us for the Serverless Conference on November 18, 6 PM CET. This online event is organized by Prisma, with speakers from companies at the leading edge of serverless technologies and database access at scale. Adopting serverless comes with many challenges, but provides speed, efficiency, and scalability while allowing application developers to focus more on their code and features instead of the infrastructure. Prisma is a leader in the core functionality of database access in serverless environments, and for this conference, we have gathered the top experts to present an exciting series of talks. During this event, you'll learn how to implement flexible, scalable, and low-cost solutions from industry leaders. This conference is a great way to gain additional insights from experts; the people and teams building the technology now! Our exciting lineup includes speakers from: 🎙️Vercel 🎙️MongoDB 🎙️Netlify 🎙️CockroachDB 🎙️PlanetScale 🎙️Cloudflare 🎟️ Register for the event and stay updated, as well as generate your unique badge here: https://www.prisma.io/serverless 🤗 The Q&A will take place in the #prismaserverless channel of the Prisma Slack: https://slack.prisma.io/
  • l

    Luis Haroldo Castro Cabrera

    11/16/2021, 5:13 PM
    dumb question, i'm deploying an application in AWS however when i deploy the prisma client i get this warn Versions of prisma@2.30.3 and @prisma/client@3.5.0 don't match. on the package.json i have client 3.5.0 am i missing something?
    ✅ 1
    j
    • 2
    • 3
  • u

    user

    11/16/2021, 6:01 PM
    🪄 The Prisma Data Proxy explained in less than 50 seconds

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

1...507508509...637Latest