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

    Kay Khan

    03/24/2022, 8:35 AM
    Hi friends, has anyone found that
    createMany
    holding onto memory of the node.js application? For more context i am looping overan array split into batches of 100k. And then inserting that 100k into the database. After each loop i notice a spike in the amount of memory the node.js application uses and it never drops (1gb, 2gb, 3gb etc). Overtime my script eventually runs out of memory 100% certain it seems like there is a memory leak in createMany
    n
    a
    • 3
    • 4
  • a

    Andrew Ross

    03/24/2022, 9:52 AM
    posted an article about unwrapping Reacts JSX.IntrinsicElements interface for global use/absolute prop control with 0 imports required. but spent the first third of it using a prisma seeding example from one of my builds as a way to ease into inferring types; how to infer the return type of a massive async seeding function with generics then use that to type props passed/returned in the function that's instantiating the giant via CLI-driven activation if you're a react/nextjs user ReactUnwrapped<JSX.IntrinsicElementsMapped> (in a nutshell) might be useful https://dev.to/asross311/unwrapping-reacts-core-access-jsxintrinsicelement-props-globally-no-imports-required-ckm
    👍 2
  • d

    David Marr

    03/24/2022, 1:55 PM
    If I make a schema change, and I don't mind losing data, shouldn't
    migrate reset
    be enough to apply that change?
    n
    • 2
    • 4
  • s

    Slackbot

    03/24/2022, 2:03 PM
    This message was deleted.
    m
    v
    • 3
    • 2
  • n

    Nathaniel Babalola

    03/24/2022, 2:06 PM
    Is Full Text-search via Prisma better than ElasticSearch ?
    m
    • 2
    • 6
  • o

    Orcioly Andrade Alves

    03/24/2022, 4:12 PM
    Boa tarde pessoal, Estou tentando usar o select dentro do create para não retornar o Password para o cliente, nas consultas com Find funcionou perfeitamente, mas na hora do create ele informa no retorno que está faltando o campo password. Alguém poderia me ajudar?
    Copy code
    import { User } from '@prisma/client';
    import { AppError } from '../shared/errors/AppError';
    import prismaClient from '../prisma';
    import { hash } from 'bcryptjs';
    import { CreateUserDTO } from '../dtos/user/CreateUserDto';
    
    class CreateUserService {
      async execute({
        name,
        email,
        password,
        admin,
      }: CreateUserDTO): Promise<User | undefined> {
        const userAlreadyExists = await prismaClient.user.findUnique({
          where: {
            email,
          },
        });
        if (userAlreadyExists) {
          throw new AppError('Email address already used.');
        }
    
        const passwodHash = await hash(password, 8);
    
        const user = await prismaClient.user.create({
          data: {
            name,
            email,
            password: passwodHash,
            admin,
          },
          select: {
            id: true,
            name: true,
            email: true,
            admin: true,
            created_at: true,
          },
        });
        return user;
      }
    }
    
    export { CreateUserService };
    n
    • 2
    • 4
  • j

    Justin Ellingwood

    03/24/2022, 4:41 PM
    đź‘‹ We just published a new article on the Data Guide about PostgreSQL connection URIs. Hopefully it'll be helpful if you're not quite sure how to encode the appropriate connection information for your server: https://www.prisma.io/dataguide/postgresql/short-guides/connection-uris
    👍 5
    prisma rainbow 2
    đź’Ż 2
  • m

    matic

    03/24/2022, 7:25 PM
    Hi everyone 👋 , We are using Prisma (3.7.0) and I’ve been a fan of it for a very long time, but recently we are experiencing an enormous amount of timeouts, slow queries and generally bad performance. We are using Sentry transactions to measure query executions and the one that stands out most prominently is
    Copy code
    client.challengeAttempt.findUnique({
      where: { challengeId_userId: { challengeId: 'ac', userId: 'dc' } },
    })
    Copy code
    model ChallengeAttempt {
      id String @id @default(cuid())
    
      challenge   Challenge @relation(fields: [challengeId], references: [id])
      challengeId String
    
      user   User   @relation(fields: [userId], references: [id])
      userId String
    
      @@unique([challengeId, userId])
    }
    My understanding is that querying a unique field should be almost instant while in our case the logs show that every day some queries need a couple of seconds (range from 200ms to 15s) to finish. We’ve also investigated that the payload is as small as it can be (and it’s small). We are currently processing at most three concurrent requests every second and the CPU/memory of our server barely scratches the potential. DB, on the other hand, is quite bad and reaches the spike every day even though we have 2GB of RAM. Apart from that, we are getting “Timeout fetching a new connection from the pool” even though the pool limit is 84 connections. (strangely, the logs show that there’s no active connection at all times) I’ve also seen this review (https://github.com/edgedb/imdbench) and wanted to ask: 1. Is 2GB of RAM for a db for an app of our size too little? 2. Is this a common problem? 3. How do you cope with low performance? At this point, we are considering switching to something else and help/feedback would be greatly appreciated 🙂
    c
    j
    j
    • 4
    • 6
  • b

    Bret emm

    03/24/2022, 8:56 PM
    Does Prisma still have the “cloud”? That it connects to Heroku as well?
    n
    • 2
    • 1
  • m

    Matthew

    03/24/2022, 10:13 PM
    Any idea why this isn't valid?
    Copy code
    import { PrismaClient } from '@prisma/client'
    import { logger } from './logger'
    
    const prisma: PrismaClient = new PrismaClient({
        log: [
            {
                level: 'error',
                emit: 'event',
            },
        ]
    })
    
    prisma.$on('error', (e) => {
        logger.error(e)
    })
    n
    • 2
    • 1
  • m

    Matthew

    03/24/2022, 10:13 PM
    Copy code
    src/prisma.ts:13:12 - error TS2345: Argument of type '"error"' is not assignable to parameter of type '"beforeExit"'.
  • m

    Matthew

    03/24/2022, 10:39 PM
    Ah, the : PrismaClient type was doing it apparently.
    👍 1
  • b

    Ben Guthrie

    03/25/2022, 3:24 AM
    Hey there! 👋 I’m seeing that the names of foreign keys can conflict when a model has two relations with the same field. Here are the
    schema.prisma
    and the generated migration sql. It looks like foreign key names are in the format of
    {tableName}_{field}_fkey
    but I’m thinking we’d want the name to be something like
    {sourceTable}_{sourceField}_{targetTable}_{targetField}_fkey
    to handle this case. Any thoughts on this? Should I submit an issue to prisma-engines?
    schema.prismamigration.sql
    n
    • 2
    • 3
  • e

    Eko Nur Arifin

    03/25/2022, 7:09 AM
    hi guys, thanks for time i need little help anyone can give me suggestion about return type function here, i can use
    'Customer & { addresses: Address[]; user: User; }'
    but i think not flexible if have any change relation hopefully can use type like
    Prisma.CustomerInclude
    but give error.
    Type 'Customer & { addresses: Address[]; user: User; }' is not assignable to type 'CustomerInclude'.
    thanks anyone help
    n
    • 2
    • 3
  • h

    Hammadi Agharass

    03/25/2022, 10:59 AM
    Hello guys, I was wondering if there’s a possibility to add metadata to the models? My end goal is to be able to add some metadata to my models and use them later on after Prisma generates the client. If it’s not possible, is there a way to extend the PSL by writing some kind of plugin and telling Prisma compiler to use my plugin when it encounters the custom token?
    n
    • 2
    • 3
  • p

    PanMan

    03/25/2022, 11:02 AM
    Counting relations can’t have a
    where
    , right? - https://www.prisma.io/docs/concepts/components/prisma-client/aggregation-grouping-summarizing#count-relations - eg, we can get all users with a count of posts, but we can’t get all users with a count of Published posts..
    n
    • 2
    • 4
  • c

    Clement Fradet Normand

    03/25/2022, 11:50 AM
    Hi Prisma team, do you know who is managing Paris Prisma Meetups ? Looks like the group has been deleted: https://www.meetup.com/fr-FR/Paris-Prisma-Meetup/ Thanks a lot !
    v
    n
    n
    • 4
    • 15
  • m

    Matheus Assis

    03/25/2022, 2:02 PM
    Is is possible to use prisma with rust the same way it’s done with node? With prisma client?
    n
    • 2
    • 2
  • a

    aetheryx

    03/25/2022, 9:32 PM
    Does Prisma support
    DELETE FROM ... RETURNING *
    ?
    n
    • 2
    • 8
  • m

    Mischa

    03/25/2022, 11:39 PM
    is azure really needed as a dependency for @prisma/migrate? it's like 17MB of deps
    Copy code
    âžś  platform git:(middleware) âś— npm ls @azure/identity                                                                                                                                                                      <aws:tombo-dev>
    platform@1.0.0 /Users/cyber/dev/platform
    └─┬ platform-infra@0.1.0 -> ./packages/infra
      └─┬ @prisma/migrate@3.11.1
        └─┬ mssql@8.0.2
          └─┬ tedious@14.4.0
            └── @azure/identity@2.0.4
    n
    • 2
    • 3
  • d

    Demian N

    03/26/2022, 3:21 AM
    I think there must be an issue related to chrome 99.0.4844.84. I recently (a few hours) went into this update and suddenly I cannot longer use prisma studio in there. It hangs out forever caused by a memory leak. It works well in Firefox.
    n
    • 2
    • 4
  • e

    Ewan Lyon

    03/26/2022, 7:25 AM
    Hello, I'm having some issues with updating our database. I imagine it's due to forgetting to run migrate on a change or something but I'm really new to Prisma and its workflows so I'm a bit stuck on what to do. That image shows a change I did prior to the one I'm trying to do now and it seems I forgot to migrate that one as well. I cannot reset the database (prod). I've tried following the guides on here: https://www.prisma.io/docs/guides/database/production-troubleshooting#migration-history-conflicts specifically with the moving fowards but the resultant forwards.sql only includes information about the change I'm currently trying to do and has nothing about the sentVerification column. I am using a CMS called KeystoneJS which handles the prisma schema generation but it is up to me to run the prisma commands which is where I get a bit lost.
    âś… 1
    n
    • 2
    • 3
  • a

    André Brito Fonseca

    03/26/2022, 11:48 AM
    Guys, good morning. How's everybody doing? I have a little doubt here. My model has an
    id
    (
    @id @default(uuid())
    ) and a code (an integer, unique). If I invoke
    findUnique
    and the
    where
    references only the id, I get a message that is similar to this thread: https://stackoverflow.com/questions/65998680/prisma-findunique-where-takes-only-one-unique-argument
    m
    • 2
    • 1
  • a

    André Brito Fonseca

    03/26/2022, 11:50 AM
    Can someone enlight what I'm missing here? For reference:
    Copy code
    model Kind {
      id     String @id @default(uuid())
      code   String @unique
    
      @@map("kind")
    }
    n
    • 2
    • 1
  • a

    Adrian

    03/26/2022, 12:53 PM
    Hi, is there a way to automatically create connect and disconnect a many relationship in one call. For example if I have a Post with Tags. Tag is an entity in the DB. The user can update the tags of the Post on the frontend, disconnect some, connect others, and create or connect new ones. This kind of behavior was done implicitly by TypeORM
    n
    • 2
    • 1
  • a

    Adrian

    03/26/2022, 12:53 PM
    Let's say the Post was { id: 1, tags: [1,2,3] }. It was possible to just pass new tags to the update function like { id: 1, tags: [2, 3, 4] }
    m
    • 2
    • 1
  • a

    Adrian

    03/26/2022, 12:54 PM
    Tag 1 was disconnected, Tag 2, 3 remain the same and Tag 4 was created and connected
  • e

    EndyKaufman

    03/26/2022, 4:16 PM
    Hi, I add post for connect prisma to nestjs application and deploy with github runner maybe it need some body I use flyway migration system and use introspection from exists postgres database https://dev.to/endykaufman/add-prisma-orm-to-kaufmanbot-nestjs-telegram-bot-application-3e8b
    prisma rainbow 1
    👍 2
    n
    • 2
    • 1
  • n

    Nditah Samweld

    03/27/2022, 7:58 AM
    [SOLVED]!
    Please what's wrong with the Query?
    Copy code
    Invalid `prisma.award.findMany()` invocation:
    
    {
      include: {
        member: true,
        organization: true
      },
      where: {
        deleted: false,
        member: 'cl0ebx5dy0424d6jxyfl14dsk'
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~
      },
      orderBy: {
        id: 'asc'
      }
    }
    âś… 1
    n
    • 2
    • 2
  • p

    Philipp Minder

    03/27/2022, 10:52 PM
    Hello guys. At the moment. I have prisma in my rest api. When i create some Post with relations. I sending the full relation object. Since im on typescript Prisma want the relation object and the id of the relation object. I think im doing something wrong. May someone understand this and can help me. Many thanks
    e
    n
    • 3
    • 2
1...557558559...637Latest