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

    Julien Goux

    12/07/2021, 10:22 AM
    Hello team, are interactive transactions bugs being worked on in the current sprint? We’ll soon be going to prod and we’re extra worried about these. 😅 This one in particular (we reported it with a repro) : https://github.com/prisma/prisma/issues/9584 It can break production easily.
    n
    • 2
    • 3
  • j

    Julien Goux

    12/07/2021, 10:26 AM
    We also had to adapt our whole CI around this bug when running jest integration tests because of prisma having a memory leak (our test suite time is now twice as long because of it...): https://github.com/prisma/prisma/issues/8989 I saw that your own CI is now hitting this issue too. 😅
  • j

    Julien Goux

    12/07/2021, 10:27 AM
    Outside of these two issues for us, Prisma is still a pleasure to use (yeahhhh some positivity too! 💌 )
    🙏 1
  • d

    Daniell

    12/07/2021, 1:27 PM
    https://prisma.slack.com/archives/CA491RJH0/p1638868396200900 anyone got seeding to work with ESM?
  • p

    perp

    12/07/2021, 1:33 PM
    Is there a way to generate models from the prisma schema but have them ignored for pushing to the database? Like just creating object models which you can use in the app but does not exist in the database.
  • i

    Ibad Shaikh

    12/07/2021, 1:49 PM
    Hi Prisma family👋🏻 My use case is to fetch a user's all posts average rating. • The post model contains a column 
    user_id
     which is linked to user model. • There is a rating model which contains
    user_id
    &
    post_id
    &
    value
    which stores the rating given on a specific post by a user. • How could I get the average rating. I tried but couldn't found a solution for it. Thanking in advance :)
    f
    • 2
    • 3
  • r

    rdunk

    12/07/2021, 3:07 PM
    Hello. Anyone tackled Blob uploads with Prisma+Nexus+`graphql-upload`? Can’t seem to figure it out…
  • y

    Yaakov

    12/07/2021, 3:15 PM
    Hi, I have a 3 way mapping table where one of the foreign keys are nullable. Is it possible to create a
    UNIQUE INDEX
    with a where clause? Model:
    Copy code
    model UserRoles {
      id          Int      @id @default(autoincrement())
      user_id     Int
      role_id     Int
      facility_id Int?
    
      // Mapping relations
      user     User      @relation("UserRelation", fields: [user_id], references: [id])
      role     Role      @relation("RoleRelation", fields: [role_id], references: [id])
      facility Facility? @relation("FacilityRelation", fields: [facility_id], references: [id])
    }
    I want to add the following 2 indexes:
    Copy code
    CREATE UNIQUE INDEX key_a ON user_roles (user_id, role_id)
      WHERE facility_id IS NULL;
    
    CREATE UNIQUE INDEX key_b ON user_roles (user_id, role_id, facility_id)
      WHERE facility_id IS NOT NULL;
    If Prisma does not allow me to do this, then what would be be the correct implementation for this? Thank you!
    m
    • 2
    • 2
  • s

    Stefano Giraldi

    12/07/2021, 3:45 PM
    I'm eveluating to move my project from
    Objection.js
    (Knex.js) to Prisma. In Objection.js I've a custom method `verifyPassword`in User Model Class to check password
    Copy code
    class User extends Model {
      ...
      // Compares a password to a bcrypt hash, returns whether or not the password was verified.
      async verifyPassword (password: string) {
        return await bcrypt.compare(password, this.password)
      }
      ...
    }
    Can I follow the same approach with Prisma or I need to create a custom function outside the model schema?
    n
    • 2
    • 1
  • c

    Chris Bitoy

    12/07/2021, 5:08 PM
    Hello Y’all, if my data structure looks like this (please see below), how can I model it so that I establish the “question’s id as a composite key of the data #id using Prisma?
    Copy code
    const data = [
     {
       id: 1,
       title: 'Top 5 Questions',
       questions: [
         {
           // id -> is a composite key between the title id and question id
    
           id: 10,
           question:
             'This is a question to be answered?',
           checked: false,
           input_type: 'radio',
           answers: [
             'Heard of it - never tried it before',
             'Tried it once before',
             'Buy it regularly',
             'Curious to learn more',
           ],
         },
    ]
  • t

    terion

    12/07/2021, 6:19 PM
    Is there possibility to tune prisma client's connection pool limit or something like this? When I run integration tests — big amount of sequential requests — at some point database starts just dropping connections and goes offline. This issue was not present on 3.3.0, but after update to 3.6.0 it began to rise. It seems like too many connections issue — I've had this in older tests flow with 3.3.0 when client's instances were creating per each request and connections count quickly raised, but when I've changed this and instantiated one client per process — that was fixed. And now, when I still have only one client that makes a lot of sequential requests, with 3.6.0 I have this problem
    • 1
    • 3
  • c

    Chidume Nnamdi

    12/07/2021, 7:45 PM
    🙋 Roll call! Who else is here?
  • c

    Chris Bitoy

    12/07/2021, 8:40 PM
    🖐️
  • j

    Jin

    12/07/2021, 8:53 PM
    can somebody help me to make my server run on google cloud run ? 😭
    i
    • 2
    • 8
  • j

    Jordansz

    12/07/2021, 9:18 PM
    hello everyone, prisma newbie here.. im trying to write some seeds in my node application towards prisma but really stuck at it.
  • j

    Jordansz

    12/07/2021, 9:19 PM
    im still getting strange errors in lint or when running the seed that I dont understand on know how to interpret, anyone care to take a look? im from rails background 15+ years
  • j

    Jordansz

    12/07/2021, 9:20 PM
    something like
    Copy code
    Type '{ status: string; }' is not assignable to type '(Without<ScreeningCreateInput, ScreeningUncheckedCreateInput> & ScreeningUncheckedCreateInput) | (Without<...> & ScreeningCreateInput'''
  • j

    Jordansz

    12/07/2021, 9:20 PM
    what does this error mean? i just having some code that injects the data per column in the to be created object.
  • d

    Domenico Rutigliano

    12/07/2021, 11:42 PM
    G'day people
  • d

    David

    12/08/2021, 2:43 AM
    hi guys, just want to have quick confirmation a bit confused with
    db.decimal
    . if I set it as
    db.decimal(9,4)
    , should it be like this
    <tel:1234567891234|123456789.1234>
    or
    12345.1234
    ?
    j
    • 2
    • 4
  • u

    user

    12/08/2021, 8:01 AM
    Prisma Chats with Mahmoud

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

    In this video, Marketing Associate Intern Nika Music interviews Mahmoud Abdelwahab. Mahmoud is a Developer Advocate at Prisma's developer relations team. He creates videos for Prisma, helps the community, and is working on an exciting new course! The pair talk about educating vs. teaching and how cool technology really is! Connect with Mahmoud: http://twitter.com/thisismahmoud_ Check out Mahmoud's course: https://www.youtube.com/playlist?list=PLn2e1F9Rfr6k6MwzS-p9FGK1NDBxxwLPk Next: 👉 Next video: Prisma Chats w/ Carmen Berndt

    https://youtu.be/4AhO-OFM0Yg▾

    👉 Previous video: Prisma Chats w/ Emily Morgan

    https://youtu.be/31cdLSTcDbs▾

    00:35- Intro 01:40 - Getting started w/ tech world 02:46 - Differences between university and company environments 03:58 - The biggest challenge 05:53 - Favorite part of working at Prisma 07:03 - The most exciting project 08:35 - The most exciting technology 10:32 - Preferred stack 11:35 - Advice for people entering the tech world
  • b

    Barry

    12/08/2021, 8:13 AM
    hello everyone. I am very new to prisma. when I use transaction. I met some problems. look at the test code
    Copy code
    const prisma = new PrismaClient();
    prisma.$use(async (params, next) => {
      console.log('runInTransaction: ' + params.runInTransaction)
      const result = next(params);
      return result;
    })
    
    async function test1() {
      return await prisma.$transaction(async prisma => {
        return await prisma.user.create({
          data: {
            name: '3333',
            id: 3,
            email: '<mailto:asa@gmail.com|asa@gmail.com>'
          },
        });
      })
    }
    
    async function test2() {
      return await prisma.$transaction(async prisma => {
        const r = await prisma.user.update({
          data: {
            name: '4444',
          },
          where: {
            id: 4
          }
        });
        return r;
      });
    }
    
    async function main() {
      return await prisma.$transaction(async prisma => {
        let t1 = await test1(); // throw an error
        let t2 = await test2(); // put test2 in the first.
        console.log(t1);
        console.log(t2);
      })
    }
    the record which id=3 has been existed in the database, so the code will be executed throw an error. no data in database will be changed. but when I change the order test1() and test2() function.
    Copy code
    async function main() {
      return await prisma.$transaction(async prisma => {
        let t2 = await test2(); // put test2 in the first.
        let t1 = await test1(); // throw an error
        console.log(t1);
        console.log(t2);
      })
    }
    the record which id=3 has been updated in database. although the test1 throw an error. so this is the question, why the transaction is not rollback. I know I use nested transaction.
    Copy code
    async function main() {
        return await prisma.$transaction(async prisma => {
          try {
            // id = 3 existed in database so it will be an error
             await prisma.user.create({
              data: {
                name: '3333',
                id: 3,
                email: '<mailto:asa@gmail.com|asa@gmail.com>'
              },
            });
          } catch (error) {
            
          }
      
          await prisma.user.update({
            data: {
              name: '4444',
            },
            where: {
              id: 4
            }
          });
      
        })
      }
    I use try catch around the create(id=3). just in one transaction . the transaction also not rollback. if remove try catch block the transaction works well. It is not same with JAVA. in java no matter use try catch or not . the transaction will be rollback. so I am very confused now. does the transaction have hooks like "afterCommmit" "afterRollback"?
  • a

    Adrian

    12/08/2021, 8:56 AM
    Well, how does the transaction knows when to rollback? I assume it catches an error emited by Prisma when creating and if you add a try catch you are stopping the error propagation
    b
    • 2
    • 4
  • a

    Adrian

    12/08/2021, 8:58 AM
    You are also missing an "await" in test2
  • a

    Adrian

    12/08/2021, 8:58 AM
    Has anyone experience migration from TypeORM to Prisma?
  • a

    Adrian

    12/08/2021, 9:21 AM
    Is the Rust Query Engine open sourced?
  • a

    Adrian

    12/08/2021, 9:59 AM
    Hi, quick question. Is it possible that the prisma generate exports into another directory then the npm_modules? Would be interesting for nx mono repo to export this into a library
    👀 1
    b
    • 2
    • 2
  • b

    Benny

    12/08/2021, 10:29 AM
    Hi, is there a way to reference a table that is not in Prisma? I need a foreign key to a table that not in prisma schema..
  • a

    Aaron Waller

    12/08/2021, 11:51 AM
    Hey guys, I’m currently facing the problem that my Prisma GraphQL API stops working as soon as I deploy it to digitalOcean. I think it has something to do with my environment variables. This is the error I get:
    Copy code
    Error validating datasource `db`: the URL must start with the protocol `mysql://`
    Can someone please look into my problem, I am stuck with this for 6 days now… Seems like no one knows what the problem is, I even hired experts on Fiverr and codementor but no one is able to fix it. https://stackoverflow.com/questions/70272207/node-js-graphql-api-stops-working-as-soon-as-i-deploy-it-error-validating-data
    m
    • 2
    • 1
  • i

    Iradukunda Irenee

    12/08/2021, 11:52 AM
    hello @here any help for this
    r
    m
    • 3
    • 14
1...517518519...637Latest