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

    Josh

    05/15/2021, 10:34 PM
    An ...interesting discussion around prisma happening on Reddit: https://www.reddit.com/r/programming/comments/ncldcp/prisma_orm_how_to_use_the_great_database_mapping/
  • y

    yoenho park

    05/16/2021, 9:12 AM
    Hi ! How to implement file upload with graphql + nexus ? any good example ? 🤔
    c
    • 2
    • 2
  • b

    Beyond

    05/17/2021, 4:34 AM
    How do I count the all number of rows in a particular table, fetch and limit it in the same query? Because I don't wanna have a separate count query. E.g prisma.course.findMany({ where: {}, select: { _count: true; }, take: 20 })
    r
    • 2
    • 2
  • m

    Mo El

    05/17/2021, 7:05 AM
    Is there a way to cast the JSON column to a specific typescript type? Given the
    jsonColumn
    on the user table, it'd be ideal to have typescript checking on what is passed. This would currently fail:
    Copy code
    function createUser(someJson: { foo: string, bar: string}) {
      prisma.user.create({data: { name: 'joe', jsonColumn: someJson }})
    }
    👀 1
    👍 1
    r
    • 2
    • 9
  • t

    Tobias Lins

    05/17/2021, 4:06 PM
    anyone got prisma working within docker (also sync the client if its regenerated on host) I’m currently trying to sync following files:
    Copy code
    .prisma/client/index.js
    .prisma/client/index.d.js
    .prisma/client/index-browser.js
    .prisma/client/schema.prisma
    s
    • 2
    • 2
  • b

    bajras

    05/17/2021, 4:33 PM
    Hey guys im super new to prisma and trying to get the prima client going for my node app to read data from the database. I did the
    npx prisma introspect
    to get the schema from my RDS mysql database. But when I run the
    prima generate
    I get bunch of errors. some of them are below:
    errors:
    Copy code
    error: Type "BigInt" is neither a built-in type, nor refers to another model, custom type, or enum.
    id               BigInt          @id @default(autoincrement())
    
    Error validating model "template_save_images": The index definition refers to the unknown fields template_save_id.
    @@index([template_save_id], name: "index_template_save_images_on_template_save_id")
    Schema:
    Copy code
    model template_save_images {
      id               BigInt          @id @default(autoincrement())
      template_save_id BigInt?
      s3_url           String          @unique @db.VarChar(255)
      mc_url           String?         @db.VarChar(255)
      thumbnail        Boolean         @default(true)
      frame            String          @db.VarChar(32)
      multiplier       Decimal         @db.Decimal(5, 2)
      created_at       DateTime        @default(now())
      updated_at       DateTime        @default(now())
      template_saves   template_saves? @relation(fields: [template_save_id], references: [id])
    
      @@index([mc_url], name: "index_template_save_images_on_mc_url")
      @@index([template_save_id], name: "index_template_save_images_on_template_save_id")
    }
    
    model template_saves {
      id                   BigInt                 @id @default(autoincrement())
      user_id              BigInt?
      brand                String                 @db.VarChar(64)
      template             String                 @db.VarChar(64)
      country              String?                @db.VarChar(2)
      data                 Json?
      shipment_id          String?                @db.VarChar(32)
      source               String?                @db.VarChar(32)
      environment          String?                @db.VarChar(32)
      created_at           DateTime               @default(now())
      updated_at           DateTime               @default(now())
      users                users?                 @relation(fields: [user_id], references: [id])
      template_save_images template_save_images[]
    
      @@index([brand, created_at], name: "index_template_saves_brand_created")
      @@index([brand, template, created_at], name: "index_template_saves_brand_template_created")
      @@index([created_at], name: "index_template_saves_created")
      @@index([user_id], name: "index_template_saves_on_user_id")
      @@index([shipment_id], name: "index_template_saves_shipment_id")
      @@index([template, created_at], name: "index_template_saves_template_created")
      @@index([user_id, brand, created_at], name: "index_template_saves_user_brand_created")
      @@index([user_id, brand, template, created_at], name: "index_template_saves_user_brand_template_created")
      @@index([user_id, created_at], name: "index_template_saves_user_created")
      @@index([user_id, template, created_at], name: "index_template_saves_user_template_created")
    }
    
    model users {
      id             BigInt           @id @default(autoincrement())
      username       String           @unique @db.VarChar(12)
      created_at     DateTime         @default(now())
      updated_at     DateTime         @default(now())
      template_saves template_saves[]
    }
    ✔️ 1
    j
    j
    • 3
    • 32
  • a

    ali

    05/17/2021, 6:03 PM
    Hi ... anyone tried the PostgreSQL example here: https://www.prisma.io/docs/concepts/components/prisma-client/crud#delete-all-records-from-all-tables I get this error:
    Copy code
    Error: 
    Invalid `prisma.queryRaw()` invocation:
    
    
      Your raw query had an incorrect number of parameters. Expected: `0`, actual: `1`.
    This happens on the
    TRUNCATE TABLE
    command. Do the variables need to be formatted differently?
    • 1
    • 1
  • s

    Spiros - Product at Prisma

    05/18/2021, 10:39 AM
    Posting for visibility: https://prisma.slack.com/archives/C01739JGFCM/p1621334357000300
  • c

    Catalin Pit

    05/18/2021, 2:43 PM
    Hey!
    👋 2
    🙌 1
    r
    t
    • 3
    • 4
  • m

    Matt Leyrat

    05/18/2021, 4:46 PM
    hey everybody! 👋
  • i

    Ivano Garcia

    05/18/2021, 6:39 PM
    Hi! i have a question Has anyone tried sort by 
    jsonb
     parameter a record using a findMany. By example
    ORDER
    BY
    *name*->> 'en' *asc*
    Thanks!
    r
    • 2
    • 1
  • m

    Michael Gummelt

    05/18/2021, 11:06 PM
    ts-node-dev
    is supposed to restart my express server whenever a change is made, but when I construct a
    PrismaClient
    , the server hangs and no longer restarts when source files change. Has anyone experienced this? Running
    kill
    on the server doesn't successfully terminate it, and I've confirmed the problem is some interaction between
    ts-node-dev
    and
    PrismaClient
    , because when running under
    ts-node
    , I can
    kill
    the server just fine.
    r
    r
    • 3
    • 2
  • e

    Ethan Zoller

    05/19/2021, 12:29 AM
    Can we use Prisma with PlanetScale?
    j
    h
    • 3
    • 11
  • s

    sapkra

    05/19/2021, 3:00 AM
    What's the future of nexus? There has been no release since end of last year?
    n
    • 2
    • 4
  • p

    Pascal Sthamer

    05/19/2021, 7:11 AM
    Hey! 👋 I get a lot of these issues recently:
    Copy code
    Error: Timed out fetching a new connection from the pool. Please consider reducing the number of requests or increasing the `connection_limit` parameter (<https://www.prisma.io/docs/concepts/components/prisma-client/connection-management#connection-pool>). Current limit: 10.
    They seem to occur randomly and not during high load. Once the error occurs once, it is spammed forever and an application restart is required. I already raised the connection limit to 10, which only made the error occur less frequently. I checked the database using
    SHOW PROCESSLIST
    and it shows that not a single connection is established. Another thing I noticed in more recent versions of prisma is that it logs "Fetched a connection from the pool" very often. A single request to the api will show this log line about 10 times. prisma version: 2.21.2
    r
    j
    • 3
    • 18
  • j

    James

    05/19/2021, 11:48 AM
    suppose I have query { findManyStaff(where:{...}) { hours_worked } }, is there a way I can get the SUM of all hours_worked for that where caluse?
    r
    • 2
    • 3
  • a

    Arun Kumar

    05/19/2021, 12:58 PM
    What is the difference between prisma and migrate and introspect?
    r
    • 2
    • 1
  • a

    Arun Kumar

    05/19/2021, 1:12 PM
    Getting this while trying to migrate? Will this reset ( delete the models) the db?
    Copy code
    ? - The migration `20210407081334_init` was modified after it was applied.
    - Drift detected: Your database schema is not in sync with your migration history.
    
    
    We need to reset the PostgreSQL database "test" at "01.01.4.01:5432".
  • a

    Arun Kumar

    05/19/2021, 1:13 PM
    I have done an instrospect to get the models defined directly in the DB and made some changes on the schema file to push changes to BD via migration.
    r
    • 2
    • 13
  • j

    Julien Goux

    05/19/2021, 2:29 PM
    Hello all, did anyone tested the $transaction trick for postgresql RLS? https://github.com/prisma/prisma/issues/5128#issuecomment-826679950
  • j

    Julien Goux

    05/19/2021, 2:30 PM
    Also the middleware approach to avoid adding the statement on each query : https://github.com/prisma/prisma/issues/5128#issuecomment-843888689
  • j

    Julien Goux

    05/19/2021, 2:31 PM
    There is a lot of “might work, maybe” in this issue so if no one is gonna test I’ll take some time this week-end to test it 😅
    j
    • 2
    • 1
  • j

    Julien Goux

    05/19/2021, 2:31 PM
    if it works it will be a great news 😛
  • j

    Julien Goux

    05/19/2021, 2:31 PM
    because RLS is so powerful
  • a

    Arun Kumar

    05/19/2021, 2:44 PM
    Got it error when trying to do migration and reset the database
    Copy code
    Database error code: 42704
    
    Database error:
    db error: ERROR: type "bigserial" does not exist
  • f

    Francesco Sardo

    05/19/2021, 3:42 PM
    Heya. I just saw that the syntax to update a single row has a very restrictive where clause https://www.prisma.io/docs/concepts/components/prisma-client/crud#update Basically, if I want to update an
    Article
    , I can only do so via
    db.article.update({ where: { id } , data })
    I want to be able to add more conditions in the
    where
    clause. Right now, I want to be able to say
    update({ where: { id, authorId: session.userId }
    The alternative is to do another query first to check if the current logged in user is the author, which is not too bad, but an ORM should be able to support complex update logic. Any reason why it's not allowed in Prisma?
    r
    r
    • 3
    • 2
  • a

    Arun Kumar

    05/19/2021, 4:03 PM
    I have a migration file. Is it possible to rollback the changes?
    j
    • 2
    • 7
  • j

    Jack

    05/19/2021, 4:25 PM
    Hi, I was wondering if anyone knew of a way to use custom types in my models? I am migrating from mongoose, and we were able to have custom schema types. I've searched around, but I haven't found anything that has worked
  • a

    Alex Vilchis

    05/19/2021, 8:32 PM
    Hello, guys. Is it normal that my
    useSubscription
    apollo hooks are creating multiple websocket connections? I see many requests being made on my browser (when in my mind I only need one). Do you guys know anything about websocket connection management?
  • a

    Arun Kumar

    05/20/2021, 4:17 AM
    I have a lengthy req.body and I'm directly applying it to the data in the create method. But it's throwing an error
    g
    r
    • 3
    • 2
1...433434435...637Latest