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

    Christian Goebel

    11/29/2021, 10:07 PM
    I have a very very strange issue where I don't even know where to start looking into it. I'm creating a next.js application hosted on Vercel, within I need to do imports from an external API (around 200 entries). Locally, this imports runs very nice. But once I deployed it to Vercel and I run the request there, I end up with ~350 entries, so some of them are duplicated, but not all of them. my code looks like this:
    Copy code
    let db_results
    let all_entries = await getMyEntriesFromExternalAPI();
    for (const entry of entries) {
    
        if (await doesEntryExistInDatabase(entry.invoice_id)) {
            continue
        }
    
        //... do some heavy lifting here
    
        let sub_entries = []
    
        for (let i = 0; i < entry.number_of_sub_entries; i++) {
            let sub_entry = {
                prop1: "Name",
                counter: i
            }
            sub_entries.push(sub_entry)
        }
    
        let db_input = {
            prop1: "some Value",
            prop2: entry.invoice_id,
            sub_entries: {
                create: {
                    sub_entries
                }
            }
        }
    
        let db_result = await db.mytable.create({ data: db_input })
        db_results.push(db_result)
    
    
    }
    
    console.log({ lenght: db_results.lenght })
    So I have ~200 entries in "all_entries", if I look at the database, I can see ~350 entries and "db_results.length" counts 170 entries!? All this performed on a completely empty database. Any ideas? Many thanks in advance!
    r
    • 2
    • 2
  • f

    Fergus Meiklejohn

    11/30/2021, 2:54 AM
    I have a query please about how join tables work and the prisma syntax we use to express these relations. I'm migrating a complex schema to prisma and am encountering trouble precisely defining relations with join tables. This is a simplification:
    Copy code
    model User {
        id       Int       @id @default(autoincrement())
        name     String
        comments Comment[]
    }
    
    model Comment {
        id     Int            @id @default(autoincrement())
        text   String
        userId Int
        user   User           @relation(fields: [userId], references: [id])
        room   RoomComments[]
    }
    
    model Room {
        id       Int            @id @default(autoincrement())
        name     String
        comments RoomComments[]
    }
    
    model RoomComments {
        roomId    Int
        commentId Int
        room      Room    @relation(fields: [roomId], references: [id])
        comment   Comment @relation(fields: [commentId], references: [id])
    
        @@id([roomId, commentId])
    }
    My question is this: Room can can many comments so
    comments RoomComments[]
    makes sense, but a Comment cannot have many Rooms so
    room RoomComments[]
    isn't correct. But if I remove the
    []
    I get an error in the RoomComments model and am required to make
    comment Comment?
    optional, which isn't right either. I must be missing something, I apologise, but it looks like prisma can't express the relation as I'd like. Thanks for any help you can give! :-)
    j
    l
    • 3
    • 14
  • b

    Bård

    11/30/2021, 8:57 AM
    Recently I have been getting the warning:
    Copy code
    warn(prisma-client) Already 10 Prisma Clients are actively running.
    When running
    Copy code
    npx prisma studio
    This only happens when I run the studio, the normal app is not even running and I never get the error if I only run the app. The studio is connected to the DB with a connection pool with the pgbouncer=true param. Any ideas why?
    r
    • 2
    • 2
  • u

    user

    11/30/2021, 10:45 AM
    What's new in Prisma (v3.6.0)

    https://www.youtube.com/watch?v=12c1geyFOt4▾

    Daniel and Niko from the Prisma team discuss the latest 3.6.0 release of Prisma and other news from the Prisma ecosystem. Tune in to learn about new releases, how to upgrade, planned features, and other interesting bits from the Prisma world.
  • m

    Marvin

    11/30/2021, 1:25 PM
    Hey everyone! I'm using PlanetScale for my DB and having
    shadowDatabaseUrl
    defined in my
    schema.prisma
    which I need for development. In production, the value is empty because I don't provide it and the deployment fails. The Prisma docs say that it's not required in production, but what's the workaround for this? Do I need to provide the env variable in production still, or can I omit it somehow?
    r
    • 2
    • 2
  • j

    joao.santos

    11/30/2021, 2:16 PM
    Hi guys, is there any alternative to https://github.com/technote-space/prisma-seeder-tools for seeding complex data in prisma? thx
  • d

    Dev__

    11/30/2021, 2:30 PM
    s
  • r

    Raif Harik

    11/30/2021, 2:39 PM
    Hi, I am just going live with a project. Of course I already need to change the schema. Prisma creates a migration that uses DROP/ADD which loses data. There is a nice section of the docs describing how one can change the migration script to use a data preserving syntax. My question is, why does Prisma not elect to use the data preserving syntax as it's default. I would guess that it might somehow be much more complicated, but I'm curious to know.
    m
    • 2
    • 3
  • c

    Chris Bitoy

    11/30/2021, 2:43 PM
    @joao.santos - There is faker: https://www.npmjs.com/package/faker
    👍 1
    👍🏻 1
  • r

    Raif Harik

    11/30/2021, 2:43 PM
    @joao.santos Hi, I have a use case where I seed data for specific test cases. The seeder is really just a cli hook that runs some Prisma Inserts. It actually looks exactly like your production code. You can write a series of statements to seed the db in any manner you like. The only alternative I can think of is if you have some kind of datadump from an existing db. In which case, I imagine there's a Prisma command for running straight sql code. You would just have a seed file that reads your data dump and uses said dump in said Prisma command
    👍 1
  • r

    Raif Harik

    11/30/2021, 2:44 PM
    or, ... I guess you probably mean like what @Chris Bitoy is suggesting, in which case there are a couple packages like that. But again you'd just use that package in the regular seed script
  • j

    joao.santos

    11/30/2021, 2:48 PM
    Thx guys, i got it working but its really weird when u have many to many relations in almost every table, im not using faker becouse most of the time it doesnt connect in the relation table... I know this is my problem, not prisma, but it's really confusing to me...
  • u

    user

    11/30/2021, 3:18 PM
    TypeScript Berlin Meetup #8 - Robert Wolff - Dealing with untyped runtime libraries in TypeScript

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

    ◭ Runtime libs are sometimes required in projects. But runtime means: the TypeScript compiler cannot protect us from fat-fingering bugs into the codebase. In this talk, Robert will present ways to still have a great developer experience and type safety. ◭ Robert is a Software Engineer at idealo. He’s working with the payment team and is a member of idealo’s design system community of practice where he contributes to awesome (and type-safe) libraries. ◭ Get in touch with Robert: https://github.com/rowolff ◭ Join our TypeScript Berlin Meetup group: https://www.meetup.com/TypeScript-Berlin
  • j

    John McElreavey

    11/30/2021, 3:37 PM
    Is there any plans to make Prisma more unit testable? At the moment I have to spin up a docker MySQL instance and migrate and seed it. Would be nice if we could use something lighter
    c
    n
    r
    • 4
    • 5
  • c

    Chris Bitoy

    11/30/2021, 3:47 PM
    Is anyone here a Prisma guru. I am new to Prisma, and having problems with connecting nested data
  • p

    Paul

    11/30/2021, 3:57 PM
    Hey. What does VS Code extension now uses a Wasm module mean? Intellisence lookups for table names and schema should now be faster? Thanks
  • p

    Paul

    11/30/2021, 3:58 PM
    Also Prisma team thanks for finally closing https://github.com/prisma/prisma/issues/8854. 👍
  • t

    Tom MacWright

    11/30/2021, 4:13 PM
    From me and folks using transactions 😘 thx prisma team for 3.6.0 and the concurrency fix!!
    🙌 3
    prisma cool 3
  • g

    Garrett Tolbert

    11/30/2021, 4:23 PM
    Can anyone help me out with this issue I'm having? https://prisma.slack.com/archives/C01ACF1DJ1M/p1638288477013700
    m
    • 2
    • 4
  • d

    Daniell

    11/30/2021, 4:32 PM
    Hi! How would you store the string representation of a Snowflake in a Postgres database? https://developer.twitter.com/en/docs/twitter-ids Currently using
    id        String   @id @db.VarChar(19)
    but maybe there is something more accurate
  • j

    James Homer

    11/30/2021, 5:30 PM
    Hi, is it possible to get the query that prisma would run without executing it? If that makes sense!
  • j

    James Homer

    11/30/2021, 5:31 PM
    I just need to replace a part of the query - specifically to cast a field
  • j

    James Homer

    11/30/2021, 5:33 PM
    Can I use middleware for this?
  • c

    Cliff

    11/30/2021, 5:40 PM
    Hey Prisma team, is there a timeline for when the golang client will be GA?
    t
    • 2
    • 3
  • j

    James Homer

    11/30/2021, 5:43 PM
    nvm https://github.com/prisma/prisma/issues/5052
  • m

    Maguire Krist

    11/30/2021, 6:04 PM
    Hey
  • m

    Maguire Krist

    11/30/2021, 6:04 PM
    My prisma rawQuery is returning data that is different when running the same query but directly into pg terminal
  • m

    Maguire Krist

    11/30/2021, 6:05 PM
    So... kinda stuck, don't know why
  • w

    Wahyu

    11/30/2021, 6:29 PM
    I really love Prisma dev ux but i just can’t find a good managed serverless db that matches with my serverless deployment, does anyone have a recommendation? The one thing closest is AWS aurora serverless via Data API but that’s not supported yet
    j
    k
    t
    • 4
    • 3
  • d

    Daniel De La Luz

    11/30/2021, 8:15 PM
    Hey team. Anybody have example form jest test. I am using nestjs microservices ans prisma.
    t
    • 2
    • 5
1...513514515...637Latest