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

    cedric

    08/26/2021, 4:20 PM
    any tips?
  • v

    Victor Mimo

    08/26/2021, 5:00 PM
    Quick Q! has anyone stumbled upon a tutorial to setup Prisma with Aurora Serverless and AWS Fargate? I saw a blog post by @Ryan that was using EC2 I believe. Curious if using Fargate would change the VPC settings at all
    c
    r
    • 3
    • 4
  • s

    Sam Bunger

    08/26/2021, 6:25 PM
    hey all! Is there any way to turn off foreign key constraint generation when I run
    prisma db push
    ? Here is my schema:
    Copy code
    model profiles {
      id                   String          @id
      first_name           String?
      last_name            String?
      phone_number         String          @unique
      phone_number_ref     contacts[]
      contacts_ref         contacts[]      @relation("contact_holder")
    }
    
    model contacts {
      id                 Int       @id
      contact            String?
      contact_ref        profiles? @relation(fields: [contact], references: [phone_number])
      contact_holder     String
      contact_holder_ref profiles  @relation("contact_holder", fields: [contact_holder], references: [id])
    }
    Every profile has an
    id
    and a
    phone_number
    . Each user in the
    profiles
    table will have each of their contacts on their phone put into
    contacts
    as individual rows.
    contact_holder_ref
    will always reference a user
    id
    in the
    profiles
    table. But a user’s contacts might may or may not reference another profile’s
    phone_number
    in the
    profiles
    table. Foreign key constraints are getting created by prisma that prevent me from adding phone numbers in
    contacts
    that don’t exist in
    profiles
    . Is there anything I can do to stop
    contacts_contact_fkey
    from getting created? Everything seems to work when I manually delete the constraint, but then I can’t run
    prisma db push
    again.
    c
    r
    • 3
    • 5
  • c

    Craig A. Cook

    08/26/2021, 6:27 PM
    Hmm, I have a question, is there any way to have a sort of generic "Bridge Table" in a Prisma schema? Like. e.g., "Taggable" which would have fields: id, tag_id, taggable_id, taggable_type (which would be an enum of the possible tables linked to). This pattern can be done easily enough in SQL (with where clause for select, and a field inserted in creates/updates) and is pattern that was (possibly is, haven't done it in a while) in the ActiveRecord component of Rails. If a domain has lots of many-on-many relations it can help keep down a proliferation of bridge tables. I'm concerned the "@ relation" directive makes this not possible.
    c
    t
    • 3
    • 16
  • u

    user

    08/27/2021, 6:00 AM
    Seeding the Database using Prisma

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

    Blog Post: https://www.prisma.io/blog/fullstack-nextjs-graphql-prisma-oklidw1rhw Code: https://github.com/m-abdelwahab/awesome-links Learn more about Prisma: ◭ Website: https://www.prisma.io​​​ ◭ Docs: https://www.prisma.io/docs​​​ ◭ Quickstart: https://www.prisma.io/docs/getting-started/quickstart-typescript
  • m

    manuel

    08/27/2021, 7:23 AM
    Hey everyone! Is it possible to connect to several databases with the same prisma client?
    d
    r
    • 3
    • 6
  • r

    Rubèn Suet Marcos

    08/27/2021, 9:50 AM
    Hi, Everyone. I have a question that I haven’t been able to solve so far. Please let me know if this is not the correct channel to ask ,and I will move the question to the proper channel. It’s about Prisma queries types when the
    include
    is present. I am requesting to Prisma in a function from a class, and want to be able to catch properly the type for the next class( kind of controller/model). It’s a NestJs app build in TS. I created a gist to give some context and my questions there https://gist.github.com/Ruffeng/0aa09c13792fe5d797d54756843f9faa Any help is highly appreciated 🙂
    r
    • 2
    • 5
  • n

    Nima

    08/27/2021, 12:47 PM
    Hi we have started getting this error on Prisma cloud
    j
    • 2
    • 13
  • p

    Pedro Paulo Almeida

    08/27/2021, 9:47 PM
    Hey all. I need help with multiple relationships between the same tables. Imagine this scenario: I have “Plug” model and “Signal” like this:
    Copy code
    model Plug {
      id               Int       @id @default(autoincrement())
      // other fields, then...
      latest_signal_id Int?      @unique
      latestSignal     Signal?   @relation(fields: [latest_signal_id], references: [id])
      signals          Signal[]
    }
    
    // Then the Signal model:
    
    model Signal {
      id             Int       @id @default(autoincrement())
      plug_id        Int
      plug           Plug      @relation(fields: [plug_id], references: [id])
    
      tag_id         Int
      @@unique([plug_id, tag_id], name: "plug_signals_plug_id_tag_id_unique")
    }
    As you can see, in “Plug” model I want to have TWO relationships with the Signal model. One of then is: “A Plug has a LIST of Signal, the “signals” relationship”. Then the second one: “Signal have a direct pointer to the “latest” Signal. This “latest signal” is defined by the “latest_signal_id” column in Plug model. I’m getting the following errors from VSCode Prisma plugin:
    Copy code
    Error validating model "Plug": Ambiguous relation detected. The fields `latestSignal` and `signals` in model `Plug` both refer to `Signal`. Please provide different relation names for them by adding `@relation(<name>).
    How can I have this kind of “two relationships” at the same time? What am I doing wrong here? Because I put that
    @relation(fields: [latest_signal_id], references: [id])
    in front of prop
    latestSignal
    but it didn’t work.
    r
    • 2
    • 1
  • s

    Sam

    08/28/2021, 2:07 AM
    Hey everyone, I'm trying to create a CRUD app on React + Prisma + Sqlite but unsure how to proceed I'm trying to delete the post, so I have an express server and have created these functions:
    app.delete('/posts/:id', deletePost);
    export const deletePost = async (req: Request, res: Response) => {
    const { id }: { id?: number } = req.params;
    const post = await prisma.post.delete({
    where: {
    id: Number(id),
    },
    })
    res.json(post)
    };
    Now I'm trying to link it with the <PostTable> page... So I have a PostList.ts page, which calls fetch in a UseEffect and gets all the posts then passes it to <PostTable posts={posts}> So in my PostTable.ts file, I have a posts.map () and then on the delete button, I'm trying to figure out how to delete it I'm really confused if I need to call useEffect, deletePost (which doesnt work), and then how do I update the page? Should I pass the setPosts from PostList to PostTable? Not sure if I need to call prisma or update the posts using setPosts
    r
    • 2
    • 1
  • v

    Vdrizzle

    08/28/2021, 2:39 AM
    Hi all. I'm trying to get prisma to work with NextJS but I'm running into an issue where I have to manually copy schema.prisma manually to the build folder. Does anyone know of a way to have this done automatically?
    r
    • 2
    • 1
  • u

    user

    08/28/2021, 7:01 AM
    Using Prisma Studio to View the Data in Our Database

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

    Blog Post: https://www.prisma.io/blog/fullstack-nextjs-graphql-prisma-oklidw1rhw Code: https://github.com/m-abdelwahab/awesome-links Learn more about Prisma: ◭ Website: https://www.prisma.io​​​ ◭ Docs: https://www.prisma.io/docs​​​ ◭ Quickstart: https://www.prisma.io/docs/getting-started/quickstart-typescript
  • a

    Adrian

    08/28/2021, 11:09 AM
    Hi, i have this simple SQL query
    Copy code
    SELECT s.id, s.name, s.logo_url
      FROM supplier AS s
      JOIN supplier_user su ON s.id = su."supplierId"
     WHERE su."userId" = ${id}
       AND su.active = TRUE
    I tried to build this with a prisma query but i don’t get this to work. May last try was:
    Copy code
    return this.prisma.supplier.findMany({
      where: {
        supplierUser: {
          some: {
            active: true,
            userId: { equals: id }
          }
        }
      }, select: {
        id: true,
        name: true,
        logoUrl: true,
      }
    });
    can someone pleas help me to understand why and how this joined selects work?
    h
    r
    • 3
    • 11
  • g

    glekner

    08/28/2021, 12:37 PM
    tsc
    passes locally but fails on herku. any suggestions?
  • g

    glekner

    08/28/2021, 12:37 PM
    Copy code
    src/schema/branch/types/BranchMutation.ts(42,36): error TS7006: Parameter 'l' implicitly has an 'any' type.
           src/schema/branch/types/BranchMutation.ts(52,36): error TS7006: Parameter 'l' implicitly has an 'any' type.
           src/schema/branch/types/BranchMutation.ts(53,47): error TS7006: Parameter 'l' implicitly has an 'any' type.
           src/schema/payloads.ts(62,7): error TS2339: Property 'date' does not exist on type 'ObjectDefinitionBlock<"TasksByThisWeekGroupByPayload">'.
           src/schema/task/types/Task.ts(18,7): error TS2339: Property 'date' does not exist on type 'ObjectDefinitionBlock<"Task">'.
           src/schema/task/types/Task.ts(19,15): error TS2339: Property 'date' does not exist on type 'Omit<OutputDefinitionBlock<"Task">, "nonNull" | "nullable">'.
           src/schema/task/types/Task.ts(20,15): error TS2339: Property 'date' does not exist on type 'Omit<OutputDefinitionBlock<"Task">, "nonNull" | "nullable">'.
           src/schema/task/types/Task.ts(21,15): error TS2339: Property 'date' does not exist on type 'Omit<OutputDefinitionBlock<"Task">, "nonNull" | "nullable">'.
           src/schema/task/types/Task.ts(35,7): error TS2339: Property 'date' does not exist on type 'InputDefinitionBlock<"TaskCreateInput">'.
    r
    • 2
    • 1
  • g

    glekner

    08/28/2021, 12:37 PM
    I dont have any of these errors locally
  • l

    Luis España

    08/29/2021, 2:06 AM
    Hi there, has anybody developed a electron app using prisma? I have some problem when packaging my app, it throws an error saying
    spawn C:\Users\OneDrive\Escritorio\electron-template\dist\win-unpacked\resources\static\query-engine-windows.exe ENOENT
    i have looked into that folder and the file is actually there, can someone help me out?
  • r

    Rain

    08/29/2021, 8:31 AM
    Hi, I have a startTime field with DateTime @db.time , what is the format to insert the time ? I tried "090000" but my seed break
    r
    • 2
    • 3
  • k

    kkangsan

    08/29/2021, 5:36 PM
    many_upsert.ts
  • k

    kkangsan

    08/29/2021, 5:36 PM
    I know that many upsert queries don't exist. Any good many(multiple) upsert examples? I wrote the code like this Do you have any other good way? code # 3 - Is there a problem with using promise.all ?
    r
    • 2
    • 20
  • u

    Ugogo

    08/29/2021, 6:15 PM
    Quick question guys, is there a way to access
    prisma studio
    on Heroku? The output is
    Copy code
    Running npm run studio on ⬢ mealy-db... up, run.4905 (Free)
    
    > rev@1.0.0 studio
    > blitz prisma studio
    
    Environment variables loaded from .env
    Prisma schema loaded from db/schema.prisma
    Prisma Studio is up on <http://localhost:5555>
    But there is no localhost on Heroku 😁
    s
    • 2
    • 4
  • m

    Maximous Black

    08/29/2021, 6:35 PM
    This could be an FAQ but Is there a proper way of syncing the schema between multiple repos? we have five repo that need the latest revision of the schema, what would be the best way to sync the schema between all repos?
    k
    r
    • 3
    • 11
  • k

    Kyle (TechSquidTV)

    08/29/2021, 7:45 PM
    Hey folks, I wanted to post this to the appropriate channel though im sure this one is more more frequented. I am just trying to get off the ground and having some issues with my generated client and the types it produces if anyone might be able to take a look at let me know what they think. thank you. https://prisma.slack.com/archives/CCWDULGUW/p1630258320018900
  • c

    Chris Packett

    08/30/2021, 5:45 AM
    Hi all, does prisma client work within a bull queue / worker process?
    r
    • 2
    • 10
  • m

    Medea T

    08/30/2021, 9:37 AM
    When will prisma2 subscriptions be available ?
    r
    • 2
    • 1
  • p

    Prisma

    08/30/2021, 11:40 AM
    Await prisma. Orders({where{owner{id_contains:Owner.id}}})
    r
    • 2
    • 4
  • p

    Prisma

    08/30/2021, 11:40 AM
    How can i write this prisma1 syntax in prisma2 format
  • p

    Prisma

    08/30/2021, 11:41 AM
    Pls help🙏
  • n

    Nima

    08/30/2021, 1:21 PM
    Hey guys just FYI the cloud Prisma studio isn't working: https://github.com/prisma/studio/issues/770 (I see a couple of other issues before, those are reported from the online version)
    f
    • 2
    • 3
  • a

    Alan

    08/30/2021, 2:24 PM
    Any ideas why all my foreign keys must be renamed with Prisma migrate (MySQL)? https://github.com/prisma/prisma/discussions/8981
    j
    • 2
    • 1
1...475476477...637Latest