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

    Yassine

    04/17/2021, 5:11 PM
    Hey everyone, Is it possible to attach custom metadata at the model level in the prisma schema, eg:
    Copy code
    @Metadata({
      generate: true
    })
    model Product {
      id             String               @id @default(cuid())
      name          String
    }
    I want to build a custom generator, that helps me generate crud services, and react components, based on my prisma schema, so i wonder if something like this, is possible.
    r
    • 2
    • 2
  • b

    Benjamin

    04/18/2021, 2:08 AM
    Hi guys! I've updated to the latest version of prisma, but still can't seem to use createMany. I'm importing it from my seed file. This is my code:
    Copy code
    import { PrismaClient } from '@prisma/client'
    const prisma = new PrismaClient()
    
    const nodes = await prisma.node.createMany({
        data: [
        ]
      })
    I'm using prisma client 2.21.2. And when I specify it as a preview feature in schema.prisma it just tells me not to. The error I'm getting is
    Property 'createMany' does not exist on type 'NodeDelegate<RejectOnNotFound | RejectPerOperation | undefined>'
    f
    • 2
    • 1
  • u

    김폴빈

    04/18/2021, 5:12 PM
    anybody having a similar issue? I have prisma generator output to custom path and using webpack bundler. I added copy plugin to webpack but i dont seem to have much luck...
  • r

    Rigantona Mårtensson

    04/18/2021, 10:03 PM
    I have a question, when using implicit many-to-many relations, why is prisma not setting any primary keys on the relationship table?
    r
    • 2
    • 1
  • j

    José da Mata

    04/19/2021, 5:24 PM
    Hey 👋 I have a question, I wonder if Prisma will ever support transactions using a callback method instead supplying prisma operations as an array, or by allowing something like:
    Copy code
    try {
    
      prisma.$executeRaw("BEGIN")
    
      code code code
      code
    
      prisma.$executeRaw("COMMIT")
    } catch(e) {
      prisma.$executeRaw("ROLLBACK")
      throw e;
    }
    r
    • 2
    • 2
  • j

    José da Mata

    04/19/2021, 5:26 PM
    Some times is useful to be able to rollback a transaction based on application business logic and not on database operation success
  • j

    José da Mata

    04/19/2021, 5:27 PM
    https://github.com/prisma/prisma/issues/3152
  • j

    José da Mata

    04/19/2021, 5:28 PM
    I found this that kind of answers my question, BUT I know that it is possible depending on how Prisma binary engine works with database connections this might not work
  • j

    José da Mata

    04/19/2021, 5:29 PM
    Hope it isn't a silly question
  • j

    José da Mata

    04/19/2021, 5:30 PM
    I think as a general api it would be useful to have something like:
    Copy code
    prisma.$transaction(() => {
      code code code
      code
    });
    r
    • 2
    • 2
  • j

    José da Mata

    04/19/2021, 5:30 PM
    🙏
  • e

    Ethan Zoller

    04/20/2021, 3:06 AM
    Any project examples of a monorepo using a shared Prisma client?
    r
    • 2
    • 1
  • j

    Joey

    04/20/2021, 5:25 PM
    Has anyone experienced this error;
    Copy code
    npx prisma db seed --preview-feature
    Environment variables loaded from .env
    Prisma schema loaded from prisma/schema.prisma
    Running ts-node "prisma/seed.ts" ...
    Failed to seed data, Error: 
    Invalid `prisma.product.upsert()` invocation:
    
    
      Error occurred during query execution:
    ConnectorError(ConnectorError { user_facing_error: None, kind: ConnectionError(Timed out during query execution.) })
    r
    • 2
    • 3
  • a

    Alfred S

    04/20/2021, 9:12 PM
    Did you remove the Prisma video on youtube? I quite liked it 😁
    j
    e
    • 3
    • 5
  • m

    Magnus

    04/21/2021, 8:41 AM
    Hi, General architecture of Nextjs and Prisma question: I have been trying to understand how to structure an application that fetches data from a third-party api (eg. Twitter API) on an interval, and save part of the information to a database. It has to run continuously. (Example: say I have a list of Book names, and needs to do a third-party api query on each of those names every 3 hours.) I am familiar with Nextjs and Prisma but doesn't quite understand if that is something I'd be able to do with Nextjs API Routes. As far as I understand, API Routes is built on serverless functions but am just starting dip my toes in the water. Alternative, I think I'd need a separate backend which handles all of that? Or am I missing something? My background is as a designer with some front-end experience. I hope this type of general question is ok here. Thanks 🙂
    e
    b
    • 3
    • 3
  • j

    John McElreavey

    04/21/2021, 5:06 PM
    Hi guys, quick question. Has anyone had any luck with unit testing using prisma? At the moment we're using MySQL but the problem is we have to have a separate database to run unit tears against. Is there any nice way to mock prisma or perform the database calls on SQLite or in memory? It's just a bit slow running against a full database then wiping it down plus it'll be even slower when we implement CI/CD
    q
    j
    • 3
    • 5
  • y

    YuukiKanasugi

    04/22/2021, 1:43 AM
    Hi, everyone from Japan. I’m Yuuki Kanasugi. Japanese guy living near Tokyo. I just created my own company with my friends and decided to use Prisma with Apollo Server as a backend, and Next.js as a frontend. I want to Japanese translated Prisma doc and Prisma blog etc… Because Prisma is amazing and share this with a lots of Japanese developer. So, my question is who should I ask to get permission to translate Prisma official article, for example, this article https://www.prisma.io/blog/prisma-the-complete-orm-inw24qjeawmb ?
    😍 3
    r
    n
    • 3
    • 5
  • n

    Naresh

    04/22/2021, 1:30 PM
    Hi team new to graphql, prisma getting this error
    d
    • 2
    • 7
  • g

    George

    04/22/2021, 2:28 PM
    Is there a plan to create a desktop Electron app similar to Insomnia API tools?
    d
    • 2
    • 9
  • k

    kitze

    04/22/2021, 3:56 PM
    Hey 👋 Does anyone know of something similar to deepr? I need something like graphql resolvers, but only for js/ts. I don't want to expose a graphql api, I want to simplify the cases where I'm combining multiple prisma db calls with other external api calls to form a final object
    d
    • 2
    • 10
  • v

    venky

    04/22/2021, 5:09 PM
    Hello Everyone!! I am planning to migrate M:M to 1:1 relationship. Has anyone done this before using prisma 1.34 without any data loss and down time? The manual process is expensive.
    j
    • 2
    • 1
  • p

    Prisma

    04/22/2021, 5:38 PM
    Hi in prisma 1.I wanted to have the count of all store followers in store model how can i do it?
    j
    • 2
    • 1
  • a

    Alex Vilchis

    04/22/2021, 6:59 PM
    Hello there 👋 Is it normal behavior for my relation fields to be autocapitalized when I format with the Prisma extension? Example:
    Copy code
    model Customer {
      id        String     @id @default(cuid())
      createdAt DateTime   @default(now())
      updatedAt DateTime   @updatedAt 
      Proposal  Proposal[] // this relation field name was autocapitalized!
    }
    If this is normal, what is the reasoning behind it? 🤔
    j
    • 2
    • 7
  • s

    sal

    04/23/2021, 2:58 AM
    Why am i getting this error Unknown arg
    id
    in data.id for type CommunityCreateInput.
    e
    • 2
    • 1
  • m

    Manish Kumar

    04/23/2021, 7:54 AM
    WHERE conditions to compare columns in same table. this is my WHERE condition for mysql query: EventCD NOT IN ('DIV' , 'DRIP') and  SEDOL = ? and PrimaryExchgCD = ExchgCD How can I do PrimaryExchgCD = ExchgCD  part (column comparision) in prisma ?
    const { SEDOL } = args;
          
    //  EventCD NOT IN ('DIV' , 'DRIP') and  SEDOL = ? and PrimaryExchgCD = ExchgCD"
          
    const whereCondition = {
            
    SEDOL,
            
    EventCD: {
              
    not: {
                
    in: ["DIV", "DRIP"],
              
    },
            
    },
          
    };
    r
    • 2
    • 8
  • e

    Elvijs

    04/23/2021, 9:05 AM
    Hello, guys! I've ran into very interesting bug. I have a prisma + nexus + nexus-prisma-plugin + graphql backend which I run on AWS lambdas using serverless framework. To optimise lambda sizes I've created multiple layers. The problem I'm having is when deploying from gitlab ci-cd I get an error `You most likely forgot to initialize the Prisma Client. Please run
    prisma generate
    and try to run it again.\nIf that does not solve your problem, please open an issue.` but I've installed all packages in prismaLayer and ran prisma generate. When all operation are being done manually on my machine everything deploys nicely. Do any of you have experience working in this stack and may have any advice how could I resolve it? Thanks in advance. Happy Friday! 😉
    • 1
    • 2
  • m

    Mykyta Machekhin

    04/23/2021, 12:31 PM
    Hello guys. Try to run simple migration, and get following error. Does anyone know the possible cause?
    d
    r
    • 3
    • 8
  • o

    Ofer

    04/23/2021, 12:37 PM
    Hi, I’m having hard time to adapt the concept of supertype-subtype in Prisma schema. For example how do I implement this in Prisma schema terms? If I would do it like the typical 1-n prisma example:
    Copy code
    model Product {
      id        Int      @id @default(autoincrement())
      cars     Car[]
      boats    Boat[]
      planes.  Plane[]
    }
    
    model Car {
      id        Int   @id @default(autoincrement())
      product   Product  @relation(fields: [productId], references: [id])
      productId  Int
    }
    
    model Boat {
      id        Int   @id @default(autoincrement())
      product   Product  @relation(fields: [productId], references: [id])
      productId  Int
    }
    
    model Plane {
      id        Int   @id @default(autoincrement())
      product   Product  @relation(fields: [productId], references: [id])
      productId  Int
    }
    But it doesn’t feel intuitive to me. Is this the correct way in this case?
    r
    m
    • 3
    • 7
  • s

    Sasi

    04/23/2021, 12:52 PM
    👋 I’m here! What’d I miss?
    👋 2
  • s

    sal

    04/23/2021, 4:21 PM
    Is this not how you created the related record
    Copy code
    let group = await prisma.group.upsert({
          where: {
            id: req.body.groupId
          },
          update: {
            id: req.body.groupId
          },
          create: {
            id: req.body.groupId,
            groupMembers: {
              create: {
                role: "ADMIN"
              }
            }
          }
        })
1...428429430...637Latest