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

    Brothak

    04/19/2022, 5:46 AM
    I see a lot of ClientRead Idle connections in my postgres db. The query has been idle for 2 to 26 hours, wait_event is clientread. They are simple selects with one WHERE close and some joins. The moment I restart nodejs server they are gone.
    n
    • 2
    • 1
  • b

    Brothak

    04/19/2022, 6:28 AM
    Ou I think, I know whats going on. After connecting to db, does Prisma keep connections open and waiting for next request to come in?
    n
    • 2
    • 11
  • b

    Brothak

    04/19/2022, 6:28 AM
    so connection closes automatically only in the server is restarted?
    n
    • 2
    • 1
  • h

    henry

    04/19/2022, 6:46 AM
    Hi All, whats the advantage of using mogoose/mongodb over prisma/mongodb? is there a connections limit?
    n
    • 2
    • 1
  • j

    Jonathan Gotti

    04/19/2022, 9:05 AM
    Hi all, I can see prisma clients are generated in node_modules. Does anyone version theese files in their repo or everybody let prisma generate them in CI / CD ?
    j
    • 2
    • 1
  • n

    Natalia

    04/19/2022, 9:39 AM
    Hello <!channel>, Prisma Day 2022 is coming - this time as a hybrid event! Join us on June 15th - 16th online or in Berlin. prisma rainbow • June 15th will be a day of workshops, as we hear and learn from members of the Prisma community. For those of you who will be attending Prisma Day virtually, you’ll join us online for these workshop sessions. If you plan to attend in person, you’ll have the option to participate in the remote sessions from our Prisma office! • June 16th will be our conference day! In-person attendees will participate from the James&June Sommergarten in Berlin, a beautiful, lush outdoor setting where we can soak up the sun—and new ideas. This conference will also be live-streamed, starting at 2:00 PM CEST. 🌴 All online activities—workshops and talks—are free for everyone! For those of you who plan to attend in person, tickets are already available for purchase, and we’re offering discounted tickets for students and free diversity tickets. Get your tickets here or sign up for updates. We’re looking forward to seeing you (both remotely and in person)!
    🇲🇬 3
    👀 7
    🇬🇷 2
    🇯🇵 3
    🇱🇰 1
    🇿🇼 3
    🎉 13
    🇰🇪 2
    catjam 1
    😍 2
    💯 7
    ❤️ 9
    🇮🇳 4
    ‼️ 5
    🇰🇷 8
    🇻🇳 3
    prisma green 13
    fast parrot 14
    prisma rainbow 25
    spain parrot 4
  • u

    user

    04/19/2022, 10:01 AM
    👉 Prisma Meetup: MongoDB Edition + a raffle! 🎁 --

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

    -- Join us for a special edition of the Prisma Meetup, where we celebrate the Prisma + MongoDB Connector launch in GA. The community has long requested this feature - take a deep dive with us into its details! 🌎 Our superstar speakers: ⭐ Rachelle Palmer (@techbelle) - "Mongoose vs Prisma - a comparison" ⭐ Sabin Adams (@sabinthedev) - TBA 🌎 During this event, we will host a raffle, where you can win a copy of the "MongoDB: The Definitive Guide" book by Shannon Bradshaw
    fast parrot 1
    🙌 5
  • i

    Ibtisam Khalid

    04/19/2022, 10:07 AM
    Does prisma offer model level validations? I mean when defining model can we add validations to fields?
    n
    • 2
    • 1
  • i

    Ibtisam Khalid

    04/19/2022, 10:08 AM
    Does prisma support something like this?
    n
    • 2
    • 2
  • s

    Sönke Peters

    04/19/2022, 12:04 PM
    Does Prisma support nested queries e.g.
    SELECT ... FROM (SELECT ... FROM xxx)
    ? I need to run a query and do some more stuff (aggregation, sorting) with its results. I would like to do that in the database rather than manually in my app (e.g. with
    result.sort(...)
    or
    result..reduce(...)
    ). Is there a way?
    m
    n
    • 3
    • 6
  • a

    aj

    04/19/2022, 12:12 PM
    Prisma DB diagram generator is the great tool to have. Similar to dbdiagram.io but with prisma schema support.
    👍 1
    👀 2
    n
    t
    • 3
    • 3
  • t

    Taha Bilge

    04/19/2022, 1:21 PM
    Hey there folks! We are having issues with the binaryTargets variable in the client generator. After a version update, our team started to experience issues for which the only solution is to place the
    binaryTarget = ["native"]
    line to the
    schema.prisma
    file manually each time one of us generates the db. Are there any solutions to this that we might not be aware of? Thanks!
    n
    • 2
    • 10
  • m

    Muhammad Tahir

    04/19/2022, 1:56 PM
    I loved prisma but prisma is cont connecting to localhost mysql development environment in my PC so I am moving to sequikize. I don't want to use any other orm than prisma and I tried several tine and now I am tired and moving. Prisma working well in my aws server but not working on my development computer
    n
    • 2
    • 9
  • k

    kyohei

    04/19/2022, 2:11 PM
    Hello Prisma community! I love Prisma, but many people using Svelte Kit or Vite based frameworks seem to struggle with generated client is CJS module. I saw in GitHub someone said ESM support is near, but do we have somewhat rough ETA? or some fundamental difficulties?
    n
    • 2
    • 9
  • d

    dhatGuy

    04/19/2022, 4:04 PM
    Copy code
    model User {
      id                 String   @id @default(uuid()) /// @zod.uuid({ message: "Invalid UUID" })
      name               String
      email              String   @unique /// @zod.email({ message: "Invalid email address" })
      username           String   @unique /// @zod.min(3)
      phone              String? /// @zod.min(10).max(12)
      passwordHash       String
      emailVerified      Boolean  @default(false)
      acceptedTermsOfUse Boolean  @default(false)
      points             Points[]
      wish               String?
      createdAt          DateTime @default(now())
      updatedAt          DateTime @updatedAt
    }
    
    model Points {
      id         Int          @id @default(autoincrement()) /// @zod.int({ message: "Invalid UUID" })
      userId     String
      User       User         @relation(fields: [userId], references: [id])
      points     Int          @default(0)
      totalAfter Int          @default(0)
      desc       String
      action     PointsAction
      createdAt  DateTime     @default(now())
    }
    How do I store the total of points in the user table, please?
    a
    w
    • 3
    • 5
  • y

    Yunbo

    04/19/2022, 7:54 PM
    prisma env variable
    DATABASE_URL
    not found when used docker. in my
    docker-compose.yml
    , i'm passing
    env_file
    directive.
    Copy code
    version: "3.3"
    services:
      myapp:
        build:
          context: .
          dockerfile: ./Dockerfile
        env_file:
          - .env.dev
    this doesn't seem to work. in docker container, it ran
    npx prisma migrate deploy
    and i'm getting DATBASE_URL is missing
    w
    y
    • 3
    • 16
  • j

    Jacob Coker-Dukowitz

    04/19/2022, 10:11 PM
    The lookup path for the Query Engine appears to be off for my project. It searches in
    db/generated/client
    when it should search in
    ./db/generated/client
    : I get a 'module not found' error when prisma tries to find my query engine binary here, which results in the 'Library may be corrupt' error defined below that line. However the engine is there - it looks like the path prisma is using to find the engine is wrong. Oddly this only occurs when working in a Docker image. Code runs fine locally. Here's where it looks:
    Copy code
    prisma:client:libraryEngine Searching for Query Engine Library in db/.prisma/client +0ms
    prisma:client:libraryEngine Searching for Query Engine Library in /Users/path/to/local/directory/my-service/db/generated/client +1ms
    prisma:client:libraryEngine Searching for Query Engine Library in db/generated/client +0ms
    When I add
    ./
    in front of the path to resolve the engine as
    ./db/generated/client
    , the code works. Does the engine need to be located at the root, or is there something obvious I'm doing wrong?
    n
    • 2
    • 3
  • r

    Renato Alves

    04/19/2022, 11:47 PM
    Hey folks! I'm new to Prisma, and I have a project built in Node and Javascript. Do you know if Prisma Client works outside Typescript?
    s
    n
    • 3
    • 3
  • c

    Christopher Ehrlich

    04/20/2022, 8:55 AM
    Hi everyone, is there any way at schema level to keep the array of a one-to-many relationship ordered, or do I need to use a separate table for tracking the order?
    n
    • 2
    • 1
  • r

    Ricardo Seromenho

    04/20/2022, 3:10 PM
    👋 Hello. I have a need to get 5-15k records joining 5-6 tables and this is a bottleneck on the DB given how prisma does the "joins". For each join it creates queries with all the ids from the previous one. This is a non issue for the DB when using a join but it is an issue this way. It's not performant and the CPU is on fire. How are you dealing with this problem?
    👀 1
    o
    n
    j
    • 4
    • 15
  • d

    Dominik Jašek

    04/20/2022, 4:12 PM
    Is there any command like
    prisma generate --watch
    ? I find a bit cumbersome to execute
    prisma generate
    each time I change
    schema.prisma
    file. Or what is the best practise?
    n
    n
    • 3
    • 2
  • y

    Yunbo

    04/20/2022, 8:41 PM
    Prisma Migrate : Avoiding local db loss Steps I did 1. initial schema model 2.
    npx prisma migrate dev --name "init"
    3. threw an error saying
    type "citext" does not exist
    4.
    npx prisma migrate resolve --rolled-back "xxxx-init"
    5. it's rolled back 6. modified "xxxx-init" migration sql by adding
    Copy code
    CREATE EXTENSION IF NOT EXISTS citext;
    CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
    7.
    npx prisma migrate deploy
    8.
    All migrations have been successfully applied.
    9, added on column in one table in schema.prisma 10.
    npx prisma migrate dev --name "add_type_in_flavor"
    11. It says
    Copy code
    The migration `xxxx-init` was modified after it was applied.
    ✔ We need to reset the PostgreSQL database "postgres" at "localhost:5439".
    Do you want to continue? All data will be lost.
    i feel like i did something wrong on around step 3 when I tried to resolve the failed migration. How can I resolve this issue without losing data?
    c
    t
    • 3
    • 13
  • c

    Casey Chow

    04/20/2022, 8:42 PM
    you should be able to fix the migration state manuall and then use
    prisma migrate resolve --applied
  • r

    Ryan Westlake

    04/20/2022, 9:42 PM
    I have several
    Json
    fields defined in my models. For example:
    Copy code
    model Template {
     pages Json @default("[]")
    }
    An example of a page is:
    Copy code
    {
     title: string; // e.g. 'blah'
    }
    Because we cannot add specific types to
    Json
    fields for postgres yet, when I start looping through
    pages
    all of the keys throw a typescript error like the image below. It is a
    Prisma.JsonValue
    instead of a
    string
    . This forces me to put the values in a variable and cast them as the correct type whenever I want to reference them. As you can expect, that litters the code base with casts and is certainly not what I want. Maybe I’m missing something… how are folks dealing with this?
    c
    • 2
    • 3
  • f

    Faizan

    04/20/2022, 10:02 PM
    I am trying to
    createMany
    with a nested create, but it is not supported.
    Copy code
    Privilege.createMany({  data: { invite: { create: { data } }}});
    What alternative do I have? Thanks.
    n
    • 2
    • 1
  • e

    engineer1234

    04/21/2022, 1:33 AM
    👋 Hiya… does anyone know if you can: 1. use
    referentialIntegrity = "prisma"
    2. keep foreign keys by manually references them/setting them up (somehow) in your schema file?
    n
    • 2
    • 1
  • i

    Ian Ray

    04/21/2022, 2:51 AM
    Why does
    createMany
    not return the created models, and only a
    count
    ?
    n
    • 2
    • 2
  • k

    Kasir Barati

    04/21/2022, 7:24 AM
    Hello Any difference between:
    Copy code
    where: {
        AND: [
            {
                email: filters.email,
                fullname: filters.fullname,
                inquiryType: {
                    in: filters.inquiryTypes,
                },
                phone: filters.phone,
            },
        ],
    },
    and
    Copy code
    where: {
        AND: [
            { email: filters.email },
            { fullname: filters.fullname },
            { inquiryType: { in: filters.inquiryTypes } },
            { phone: filters.phone }
        ],
    },
    In Prisma?
    d
    • 2
    • 2
  • k

    Kasir Barati

    04/21/2022, 9:37 AM
    Copy code
    model City {
      id                    String    @id() @unique() @map("city_code_alphabet_3") @db.VarChar(3)
    
      // Relationships
      ArticleForDestination Article[]     @relation(name: "articleForDestination")
      ArticleForOrigin      Article[]     @relation(name: "articleForOrigin")
    
      @@map("cities")
    }
    
    model Article {
      id          Int          @id @default(autoincrement())
      createdAt   DateTime     @default(now()) @map("created_at") @db.Timestamptz(0)
      updatedAt   DateTime?    @updatedAt @map("updated_at") @db.Timestamptz(0)
    
      // Relationships
      destinationCityId String @map("destination_city_id")
      Destination       City   @relation(name: "articleForDestination", fields: [destinationCityId], references: [id])
      originCityId      String @map("origin_city_id")
      Origin            City   @relation(name: "articleForOrigin", fields: [originCityId], references: [id])
    
      @@index([destinationCityId, originCityId])
      @@map("article")
    }
    Problem: I can insert multiple record with the same
    destinationCityId
    and
    originCityId
    ? What is wrong?
    • 1
    • 1
  • a

    Alex Emerich

    04/21/2022, 10:00 AM
    Hey there 👋 We just published a new article on the Data Guide introducing MongoDB to those who may not be familiar: https://www.prisma.io/dataguide/mongodb/what-is-mongodb
    🙌 3
1...565566567...637Latest