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

    Tyler Clendenin

    12/22/2021, 5:03 PM
    when running various operations on a relation, (ex.
    updateMany
    ,
    create
    ,
    upsert
    ) are they run in the order they appear in the object?
    e
    • 2
    • 1
  • j

    Jay Bell

    12/22/2021, 5:09 PM
    Has anyone had success running Prisma on AWS Graviton EC2 instances? What binrary target do I need to use for the engine? We currently have these options set:
    Copy code
    binaryTargets = ["native", "linux-musl", "linux-arm-openssl-1.1.x"]
    but then once we deploy to AWS we get
    Copy code
    Error: Unknown PRISMA_QUERY_ENGINE_LIBRARY undefined. Possible binaryTargets: darwin, darwin-arm64, debian-openssl-1.0.x, debian-openssl-1.1.x, rhel-openssl-1.0.x, rhel-openssl-1.1.x, linux-arm-openssl-1.1.x, linux-arm-openssl-1.0.x, linux-musl, linux-nixos, windows, freebsd11, freebsd12, openbsd, netbsd, arm, native or a path to the query engine library.
    We are using Prisma 3.0.1, I know this is older we cannot upgrade (without some more investigtion) because of this issue https://github.com/prisma/prisma/issues/10512 We have multiple prisma schemas in our Nx repo and upgrading to the newest prisma seems to break them. cause it is looking in a hard coded spot for the schema. Ideas?
  • e

    Eden Lane

    12/22/2021, 6:24 PM
    Hi everyone! I have two tables connected via explicit many-to-many relationships: Posts and Tags. I'm trying to update a list of Tags for a particular Post, but it removes all tags from other posts. What am I doing wrong? My query is:
    Copy code
    prisma.post.update({
      data: {
        tags: [{
          create: {
            author: {
              connect: {
                id: authorId
              }
            },
            tag: {
              connect: {
                id: tagId
              }
            }
          }
        }] 
      },
      where: {
        id: postId
      }
    })
    ✅ 1
    m
    • 2
    • 2
  • x

    xoldyckk

    12/22/2021, 8:50 PM
    hello everyone
  • x

    xoldyckk

    12/22/2021, 8:51 PM
    i'm making a prisma schema for use with next-auth. Next-auth needs it to have a user table. I was thinking if can I dump user information from my app into that user table as well? or would there be a better way to organise the schema
  • g

    Gezim

    12/23/2021, 3:36 AM
    Hi folks. I'm migrating from TypeORM and running
    prisma migrate dev --create-only
    , Prisma asks me to reset the database in dev. Why is this happening?
    j
    • 2
    • 14
  • n

    Neo Lambada

    12/23/2021, 4:58 AM
    Copy code
    model Category {
      id           Int        @id @default(autoincrement())
      name         String?    @db.VarChar(255)
      image        String?    @db.VarChar(400)
      displayImage String?    @db.VarChar(400)
      parentId     Int?
      createdAt    DateTime   @default(now()) @db.DateTime(0)
      updatedAt    DateTime   @default(now()) @db.DateTime(0)
      //relationshops
      parent       Category?  @relation(name: "Subcategories", fields: [parentId], references: [id])
      subcats      Category[] @relation(name: "Subcategories")
      shops        Shop[]
      Product      Product[]
    }
  • n

    Neo Lambada

    12/23/2021, 4:59 AM
    Copy code
    {
        id: 1,
        name: 'Electornics and Mobiles',
        image:'Electronics.jpg',
        displayImage:'dvert-new.jpg',
        parentId: 0,
      },
  • n

    Neo Lambada

    12/23/2021, 4:59 AM
    Copy code
    await prisma.category.createMany({ data: electronics })
  • n

    Neo Lambada

    12/23/2021, 5:00 AM
    Copy code
    await prisma.category.createMany(
      Foreign key constraint failed on the field: `parentId`
        at cb (/app/node_modules/@prisma/client/runtime/index.js:38675:17) {
      code: 'P2003',
      clientVersion: '3.5.0',
      meta: { field_name: 'parentId' }
    }
  • n

    Neo Lambada

    12/23/2021, 5:00 AM
    why does it says constraint failed on parentId when seeding
  • s

    sagar lama

    12/23/2021, 5:04 AM
    Hello everyone, I have a user user table and a signup token table that has one-to-one relation, I'd like to delete the signup token using the user email. is there a way to do it in a single query or should I fetch the token first using the email and then make another query to delete the token.
    Copy code
    model User {
      id           Int          @id @default(autoincrement())
      email        String       @unique
      first_name   String
      last_name    String
      signup_token SignUpToken?
    }
    
    model SignUpToken {
      id         Int      @id @default(autoincrement())
      token      Int
      user       User     @relation(fields: [userId], references: [id])
      userId     Int      @unique
      created_at DateTime
      updated_at DateTime @default(now())
    }
    Can the following two queries be combined into one?
    Copy code
    const user = await this.prismaService.user.findFirst({
          where: {
            email: resendTokenInput.email
          }
        });
    
        await this.prismaService.signUpToken.delete({
          where: {
            userId: user.id
          }
        });
    c
    • 2
    • 2
  • a

    Ahmed Osama

    12/23/2021, 9:23 AM
    Hey there I am receiving this error in my schema
    Copy code
    Error validating: A self-relation must have `onDelete` and `onUpdate` referential actions set to `NoAction` in one of the @relation attributes. (Implicit default `onDelete`: `SetNull`, and `onUpdate`: `Cascade`) Read more at <https://pris.ly/d/cyclic-referential-actions>
    I am using mysql with planetscale
    Copy code
    datasource db {
      provider             = "mysql"
      url                  = env("DATABASE_URL")
      referentialIntegrity = "prisma"
    }
    
    generator client {
      provider        = "prisma-client-js"
      previewFeatures = ["referentialIntegrity"]
    }
    I am receiving the error on all relations (not only self-relations) which is weird. Also, the link given doesn't mention mysql (only mongodb and sql server) The error was not there before, It showed up out of nowhere.
    j
    • 2
    • 1
  • h

    hj yuiyui

    12/23/2021, 2:29 PM
    Hi guys i want to do something like this
    export function getGroupEventId(event_type, event_value){
     
    return runQuery(
       
    prisma.groupevent.findUnique({
         
    where: {
           
    event_type: event_type?.substr(0, 50),
           
    event_value: event_value?.substr(0, 50),
         
    }
       
    })
     
    )
    }
    I want to "select" a groupevent_id where his event_type and value are the same as parameters, how can i do that in prisma ?
    m
    • 2
    • 7
  • t

    Tyler Clendenin

    12/23/2021, 9:43 PM
    I having an issue trying to use
    set
    in an update on a many to many relationship, I'm getting the error
    The change you are trying to make would violate the required relation
    , any ideas on why this would happen before I go down the rabbithole of recreation?
  • t

    Tyler Clendenin

    12/23/2021, 10:09 PM
    to get around this It seems I have to do my own
    connectOrCreate
    and
    deleteMany
    rather than just a
    set
  • t

    Tyler Clendenin

    12/23/2021, 10:13 PM
    nm, still getting the same error
  • t

    Tyler Clendenin

    12/23/2021, 10:18 PM
    nmnm, it was still the set not working
  • m

    Maciek K

    12/23/2021, 10:23 PM
    @Tyler Clendenin Will be easier for us to debug if you post the code that's failing and schema
  • t

    Tyler Clendenin

    12/23/2021, 10:24 PM
    I think it's because it's an explicit many to many relationship
  • s

    Spencer Kifell

    12/24/2021, 4:38 AM
    is there a reason that in pure JS, it doesn't use ecmascript imports?
  • a

    arnu515

    12/24/2021, 7:30 AM
    does querying m2m relations in mongodb not work in prisma?
  • a

    arnu515

    12/24/2021, 7:30 AM
    I'm not able to do it
  • x

    xoldyckk

    12/24/2021, 1:07 PM
    How do I implement a like system for postLike, commentLike and commentReplyLike inside a Like table ?
    schema.prisma
  • x

    xoldyckk

    12/24/2021, 1:55 PM
    hello anyone there????
  • l

    Levi

    12/24/2021, 1:56 PM
    yeah
  • x

    xoldyckk

    12/24/2021, 1:57 PM
    @Levi can i have multiple model types like this or a workaround:-
    model Like{
    likedOn   ModelType  @relation(fields: [likedOnId], references: [id])
    likedOnId  String
    }
    enum ModelType{
    Post
    Comment
    CommentReply
    }
  • x

    xoldyckk

    12/24/2021, 1:57 PM
    where Post Comment and CommentReply are all models
  • x

    xoldyckk

    12/24/2021, 1:58 PM
    i want to reference likedOnId to the id fields of any one of the models Post Comment and CommentReply
  • d

    Dan Shapir

    12/24/2021, 7:27 PM
    How can one define and use partitions in postgres with Prisma?
1...525526527...637Latest