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

    Laurynn Lowe

    05/19/2022, 12:50 AM
    Hello! I am struggling with setting up Many-to-Many relationship in a graphQL resolver where the instances already exist (I'm only connecting them, not creating new instances. Does anyone know of examples I could look at? In Sequelize, I would be using
    Copy code
    fooInstance.setBar().
    r
    • 2
    • 1
  • m

    Matt Fysh

    05/19/2022, 5:13 AM
    Trying to follow the getting started guide and getting an error (will post in thread)
    r
    n
    • 3
    • 6
  • m

    Matt Fysh

    05/19/2022, 8:48 AM
    What kind of things can prevent a team member from changing the schema, followed by a
    prisma migrate
    and then checking in only the migration files and not the new schema?
    f
    • 2
    • 1
  • f

    FUTC

    05/19/2022, 10:54 AM
    Is it possible to use the interactiveTransaction API and the normal api at the same time? Or will that cause problems?
    j
    • 2
    • 2
  • g

    Geebrox

    05/19/2022, 11:26 AM
    Does anyone use prisma-aurora with
    type
    object in the schema file? It doesn’t include
    type
    in the generated schema. session.model.schema:
    Copy code
    datasource db {
      provider = "mongodb"
      url      = env("DATABASE_URL")
    }
    
    model Session {
      id               String                   @id @default(auto()) @map("_id") @db.ObjectId
      sessionId        String                   @unique
      shop             String
      state            String
      isOnline         Boolean
      scope            String
      expires          DateTime?
      accessToken      String
      onlineAccessInfo SessionOnlineAccessInfo?
    }
    
    type SessionOnlineAccessInfo {
      expires_in            Int
      associated_user_scope String
      associated_user       SessionAssociatedUser
    }
    
    type SessionAssociatedUser {
      id             Int
      first_name     String
      last_name      String
      email          String
      email_verified Boolean
      account_owner  Boolean
      locale         String
      collaborator   Boolean
    }
    Generated schema file (aurora):
    Copy code
    // ◮◮◮ GENERATED BY AURORA ◮◮◮
    datasource db {
      provider = "mongodb"
      url      = env("DATABASE_URL")
    }
    
    generator client {
      provider = "prisma-client-js"
    }
    
    model Session {
      id               String                   @id @default(auto()) @map("_id") @db.ObjectId
      sessionId        String                   @unique
      shop             String
      state            String
      isOnline         Boolean
      scope            String
      expires          DateTime?
      accessToken      String
      onlineAccessInfo SessionOnlineAccessInfo?
    }
    r
    s
    • 3
    • 11
  • b

    Berian Chaiwa

    05/19/2022, 2:45 PM
    Hello here. Anyone knows how row-level security can be implemented based on the currently logged-in user for postgres via Prisma? I am trying to figure out whether it is possible to lock editing of a record(which is a report) once it has been approved by the app user with a certain role(manager). Only managers should should enable/disable editing of an approved report, so I want this policy enforced both at the application level(which is doable) and also at the database level(via RLS policy) but using application users and that may not be database users. I have googled around but not found anything close to achieving this via Prisma. Thanks.
    j
    j
    n
    • 4
    • 7
  • l

    Luan Rodrigues

    05/19/2022, 2:49 PM
    Hi everyone, I was trying to remove a delete cascade from a many to many relation implicit, when I delete a tag that is present on a card it also deletes the card.
    Copy code
    model card {
      id              Int           @id @default(autoincrement())
      name            String?       @db.VarChar(100)
      position        Int?
    
      tags tags[] @relation("card_tags")
    }
    
    model tags {
      id            Int             @id @default(autoincrement())
      name          String?         @db.VarChar(100)
      color         String?         @db.VarChar(100)
      
      cards   card[] @relation("card_tags")
    }
    When I try to restrict the onDelete action it shows this error
    Copy code
    tags tags[] @relation("card_tags", onDelete: Restrict) // ''Error validating: Referential actions on implicit many-to-many relations are not supported''
    Any tip to proceed with this situation? Thanks!!
    n
    • 2
    • 1
  • c

    Chris Tsongas

    05/19/2022, 9:31 PM
    Is there any way to tell Prisma that a computed column should never be passed in when creating or updating a record, but will always be present when querying the table? I'm creating a computed
    fullName
    column similar to this post https://github.com/prisma/prisma/discussions/8891 with the following Prisma schema (abbreviated here for clarity):
    Copy code
    model Employee {
      id String @id @default(uuid()) @db.Uuid
      firstName                   String
      preferredFirstName          String?
      lastName                    String
      fullName                    String?
    }
    I have a trigger that computes the full name based on the required first name, optional preferred first name, and required last name, so there will ALWAYS be a full name value. Trouble is, if I make
    fullName
    not null, then Prisma requires it to be passed in, which I don't want to do. If I make
    fullName
    nullable as shown above, then I can't make it required in my GraphQL schema because Prisma says it could be null, which is inaccurate because the trigger always gives it a value. Any ideas?
    n
    • 2
    • 2
  • j

    Jared Delapasse

    05/19/2022, 10:49 PM
    I'm running into an issue where findUnique() in combination with the fluent api is not batching requests resulting in N+1 queries to the db causing a significant impact on performance. From what I understand the batching is supposed to be happening automatically. Could someone help me to debug? Screenshot of logs in thread:
    n
    • 2
    • 6
  • n

    Nathan Lands

    05/19/2022, 10:54 PM
    are most people using nexus with prisma? Seems like most of the examples use it. i find Prisma to be very simple but Nexus super confusing. Without plugin can't seem to get it to work properly.
    n
    • 2
    • 1
  • n

    Norbert Takács

    05/20/2022, 12:07 AM
    Hello everyone! I have been trying to wrap my head around how to use prisma in production. The documentation that I found is rather confusing with the migrations. This is what I want to achieve. 1. production database with prisma! ✅ 2. added new table locally ✅ 3. created migration using
    db pull
    ✅ 4. added script that runs
    npx prisma migrate deploy
    on deploy ✅ 5. deploy new migration on production 📛 I get the following error:
    Copy code
    Error: P3009
    
    migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: <https://pris.ly/d/migrate-resolve>
    The `20220503190343_multichat` migration started at 2022-05-19 23:57:48.448 UTC failed with the following logs:
    Looking into the migration that was generated it added steps that are not necessary. How would I create a migration when developing. As in how would I create a migration from STATE1 to STATE2 without the ORIGINAL_DB_STATE. So the migration only includes the last changes done to the DB (in my case adding a table). As
    db pull
    does not seem to be the answer because it creates a full migration from 0. If anyone could link me to a dev workflow with prisma that would really help
    r
    • 2
    • 1
  • j

    Jacob Simon

    05/20/2022, 12:34 AM
    Ran into this issue just now on Prisma 3.6, looks like it's been an issue before (and was apparently solved) anyone else ran into this more recently? https://github.com/prisma/prisma/issues/7712
    n
    • 2
    • 1
  • j

    Jacob Simon

    05/20/2022, 12:37 AM
    Or has anyone been able to successfully remove elements from an enum using prisma migrations?
  • j

    Jacob Simon

    05/20/2022, 12:38 AM
    There are no logs in the migrations table unfortunately
  • m

    Mischa

    05/20/2022, 5:38 AM
    i think the prisma vscode extension causes my vscode to go to 200% CPU usage for a very long time. problem goes away if i disable it. i don't have any other wacky extensions installed.
    n
    • 2
    • 3
  • m

    mkspcd

    05/20/2022, 5:57 AM
    Hi guys 👋 , I'm working on an app using Prisma and MySQL. In the Prisma Schema, is it possible to specify the type of a field as
    Date
    (YYYY-MM-DD), not
    DateTime
    ?
    EDIT : Nevermind, just found the support of native types mapping 🎉 https://www.prisma.io/docs/concepts/database-connectors/mysql#native-type-mappings
    👍 1
  • j

    Jason Kleinberg

    05/20/2022, 12:36 PM
    Start-up times for Prisma are totally fine for production, but crazy slow for tests. It’s adding about 20-30 seconds or more per test suite as the test starts up Prisma. Since I have about a hundred test suites, this is a lot of extra time. I used to be able to run our test suite in a minute or two, but now it is closer to 15 minutes. Is there a way to launch the Prisma engine as a separate process? I’d love to launch it via docker and just point my runtime clients at the engine process. Is this possible? It would also be helpful to limit the
    👀 1
    j
    • 2
    • 1
  • l

    Len Smith

    05/20/2022, 2:42 PM
    I’m trying to update a parent’s
    updatedAt
    in Prisma. Curious on thoughts of this solution (I do realize I’m missing
    updateMany
    here). Is there a better or more idiomatic way to solve keeping these dates in sync?
    j
    • 2
    • 2
  • l

    Luke Brown

    05/20/2022, 3:46 PM
    Copy code
    May 20, 04:30:02 PM: 96fdf0db ERROR  PrismaClientKnownRequestError: 
    Invalid `prisma.deployment.findFirst()` invocation:
    
    
      Client network socket disconnected before secure TLS connection was established
        at Object.request (/var/task/node_modules/@prisma/client/runtime/proxy.js:94:56)
        at t._request (/var/task/node_modules/@prisma/client/runtime/proxy.js:111:1462)
        at loader9 (/var/task/.netlify/functions-internal/server.js:444240:18)
        at Object.callRouteLoader (/var/task/.netlify/functions-internal/server.js:22913:18)
        at handleDataRequest (/var/task/.netlify/functions-internal/server.js:25968:22)
        at requestHandler (/var/task/.netlify/functions-internal/server.js:25900:22)
        at Runtime.handler (/var/task/.netlify/functions-internal/server.js:27121:24) {
      code: 'ECONNRESET',
      clientVersion: '3.14.0',
      meta: undefined
    }
    Is this error coming from Prisma?
    n
    • 2
    • 1
  • j

    James

    05/20/2022, 4:14 PM
    👋 Hello, team!
    n
    • 2
    • 1
  • p

    prisma chobo

    05/20/2022, 5:00 PM
    for mongodb, it returns null when i query like so:
    Copy code
    prisma.item.findFirst({
     where: {
      id: "....",
      deletedAt: null,
     }
    })
    But if I remove deletedAt, I get what I want. Am I approaching in wrong way? My schema is
    Copy code
    model Item {
      id                      String            @id @default(auto()) @map("_id") @db.ObjectId
      name                    String
      type                    String?
      extendedName            String
      provider                String?
      summary                 String?
      destinationCountry      Country
      description             String
      remark                  String?
      amount                  Float
      gpoint                  Float?
      gpointAmount            Float?
      display                 Boolean
      discountRate            Int?
      notes                   Note[]
      imageUrl                String
      state                   State
      createdBy               String
      expiresAt               Int
      brand                   String
      category                String            
      order                   Order?
      createdAt               DateTime          @default(now())
      updatedAt               DateTime          @default(now())
      deletedAt               Int?
    
      @@index([category])
      @@index([brand])
      @@index([name])
      @@index([provider])
    }
    n
    • 2
    • 1
  • t

    Tomáš

    05/20/2022, 6:11 PM
    Hey, why am I getting this error? using mongodb
    n
    • 2
    • 1
  • t

    Tomáš

    05/20/2022, 6:15 PM
    the 1 is an int, i checked in the db
  • r

    Rahul Taing

    05/20/2022, 8:12 PM
    Can someone provide some guidance on how to create records with prisma on tables with nullable json fields? underlying db is mysql. and I am running into an error mentioned here. also the workaround to use CreateInput throws an error
    node_modules/.prisma/client/index".Prisma' has no exported member modelNameCreateInput
    n
    • 2
    • 1
  • c

    Chip Clark

    05/20/2022, 9:30 PM
    I am getting the following error: Inconsistent column data: Could not convert value "110015 " of the field
    ClientNumber
    to type
    Int
    . The database has a ClientNumber, but it's a string with spaces at the end. I can convert the Parameter to an int, but it doesn't work. Controller:
    Copy code
    @Get(`${Route}/client/:id`)
      byclient(@Param('id') id: number  ) {
        let tempID  = id.toString();
        tempID = tempID.slice(0,6);
        return this.MatterService.MatterbyClient(+tempID);
      }
    I have also tried:
    Copy code
    @Get(`${Route}/client/:id`)
      byclient(@Param('id') id: string  ) {
        let tempID = id.slice(0,6);
        return this.MatterService.MatterbyClient(+tempID);
      }
    Service:
    Copy code
    MatterbyClient( clientid: any) {
        return Promise.all([
          this.prisma.matter.findMany({
            where: { ClientNumber: clientid  },
            select: defaultSelectQuery
          })
      }
    Schema:
    Copy code
    model Matter {
      MatterPKID              Int       @id @default(autoincrement())
      ClientNumber            String    @db.VarChar(16)
      MatterNumber            String    @db.VarChar(16)
      MatterUno               Int
      ClientUno               Int
      MatterName              String    @db.VarChar(250)
      MatterDescription       String?   @db.VarChar(Max)
      OpenDate                DateTime? @db.Date
      CloseDate               DateTime? @db.Date
      
    
      @@index([ApprovalDate], name: "ncl_Matter_ApprovalDate")
      @@index([ClientNumber], name: "ncl_Matter_ClientNumber")
    }
    I've tried setting the schema: ClientNumber Int but with no success.
    j
    n
    • 3
    • 4
  • r

    Rajkumar

    05/20/2022, 9:53 PM
    Hello Team,
  • r

    Rajkumar

    05/20/2022, 9:54 PM
    I am getting this Error: > Downloading Prisma engines for Node-API for windows [ ] 0%Error: request to https://binaries.prisma.sh/all_commits/2b0c12756921c891fec4f68d9444e18c7d5d4a6a/windows/prisma-fmt.exe.gz.sha256 failed, reason: connect ETIMEDOUT 18.65.3.78:443
    r
    r
    n
    • 4
    • 15
  • r

    Rajkumar

    05/20/2022, 9:54 PM
    can any one please help me with this
  • a

    Aaron Waller

    05/21/2022, 9:21 AM
    Can I create records based on the content of a String Array? I have a Explicit Many-to-Many relation (Category and Post) and I want to create a Post and assign categorys to it based on the content of the String Array. Here the code:
    Copy code
    const assignCategories = await prisma.post.create({
      data: {
        title: 'First Post Title',
        categories: {
          create: [
            {
              category: {
                create: {
                  name: myStringArray[0],
                },
              },
            },
            {
              category: {
                create: {
                  name: myStringArray[1],
                },
              },
            },
          ],
        },
      },
    })
    Here the Array:
    Copy code
    const myStringArray = ["Category1", "Category2", "Category3"];
    r
    • 2
    • 6
  • r

    Richard Wu

    05/21/2022, 4:37 PM
    When you have a long-running job, is it recommended to disconnect prisma in between bursts of activity when also using RDS Proxy? I saw the caveat here https://www.prisma.io/docs/guides/deployment/deployment-guides/caveats-when-deploying-to-aws-platforms that RDS Proxy is pointless since Prisma pins, but I'm wondering if explicitly disconnecting the prisma client will help with load-balancing when RDS instances failover and the connections need to be re-allocated.
    n
    • 2
    • 1
1...576577578...637Latest