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

    FUTC

    06/15/2022, 3:23 PM
    I am trying to retrieve the full record I have changed with an
    update
    call, is it possible to do some sort of
    select: { all }
    instead of manually selecting each field like this?
    Copy code
    select: {
              id: true,
              name: true,
              street: true,
              zipCode: true,
              city: true,
              person: true,
              email: true,
              telNr: true,
              faxNr: true,
            },
    ✅ 1
    a
    • 2
    • 2
  • m

    Moin Akhter

    06/15/2022, 3:26 PM
    Do we have any library with the help of which i can upload file fromt front-end or client side instead of server/backend?
    ✅ 1
    n
    • 2
    • 1
  • m

    Moaaz

    06/15/2022, 6:55 PM
    What’s the easiest way to see what SQL query is generated by a certain prisma invocation?
    ✅ 1
    k
    n
    • 3
    • 2
  • u

    Ural Bayhan

    06/15/2022, 8:03 PM
    Hey everyone, I currently have an implicit many-to-many relation in my database model. I want to switch to an explicit definition, and add some metadata to this relation. Is there any guide or best practices for this? It seems like a painful process to do manually.
    👀 1
    a
    • 2
    • 6
  • k

    Kay Khan

    06/15/2022, 8:11 PM
    Lets say i have a monrepo, i have introspected models from the database and they now live in schema.prisma.
    Copy code
    backend/
      prisma/
        schema.prisma
    frontend/
    I wanted to share types between the frontend and backend and because its a monorepo i can simply create
    shared
    folder.
    Copy code
    shared/
    backend/
    frontend/
    if i want to reuse types that are generated by Prisma in the frontend whilst also using them in the backend, how might i do this? Does this even make sense to do, "should" i move the prisma stuff over to the shared directory? Or should i really be creating a new seperate type for my api responses, even though in majority of the cases im simply returning a 1:1 of table columns and object fields.
    ✅ 1
    a
    j
    • 3
    • 12
  • g

    Gezim

    06/15/2022, 10:50 PM
    Is it not advisable to use the spread operator as an argument to a
    data
    param? For example:
    Copy code
    const store = await this.prisma.store.create({
      include: { accounts: true, shopifyOfflineSession: true },
      data: {
        ...options,
      }
    }
    I’ve not tested it thoroughly but it feels that types aren’t strictly checked like this.
    ✅ 1
    j
    n
    • 3
    • 21
  • j

    Junyu Yang

    06/15/2022, 11:48 PM
    not sure if this is a dumb q. It works when I do:
    Copy code
    const pendingRequest = await prisma.connection_request.findFirst({
                where: {
                    initiator_id: targetUserProfileId,
                    requested_id: authUserProfileId,
                }
            })
    But throw error Type ‘{ initiator_id: any; requested_id: number; }’ is not assignable to type ‘connection_requestWhereUniqueInput’. Object literal may only specify known properties, and ‘initiator_id’ does not exist in type ‘connection_requestWhereUniqueInput’. when I do
    Copy code
    await prisma.connection_request.update({
                    where: {
                        initiator_id: targetUserProfileId,
                        requested_id: authUserProfileId,
                    },
                    data: {
                      confirmed_at: new Date(),
                    },
                  })
    How can I fix it?
    ✅ 1
    n
    • 2
    • 1
  • j

    Junyu Yang

    06/15/2022, 11:51 PM
    I replaced update with updateMany to get rid of the error for now. Sounds like to use
    update
    the record has to be unique… The schema does have a that forced tho.
    @@unique([initiator_id, requested_id], map: "connection_request_idx_initiator_id_requested_id")
    ✅ 1
    n
    • 2
    • 1
  • b

    Brook MG

    06/16/2022, 5:56 AM
    Hey guys, does prisma support CHECK constraint out of the box? Like defining it in the schema.
    ✅ 1
    n
    • 2
    • 1
  • n

    Nurul

    06/16/2022, 8:25 AM
    Prisma Day is Live! 🎉 prisma rainbow

    https://youtu.be/ZbmRHU0jyPQ▾

    🙌 2
    prisma rainbow 5
    prisma cool 2
    🎉 3
  • u

    user

    06/16/2022, 10:40 AM
    The Prisma Data Platform is now Generally Available The Prisma Data Platform includes a Data Proxy, a Data Browser, and a Query Console that integrates with your current development pipeline.
    🙌 1
    💯 3
    prisma rainbow 12
  • j

    Jijin P

    06/16/2022, 4:58 PM
    whats the best way to debug this error. It was working fine before. No idea why it throws this one.
    ✅ 1
    g
    • 2
    • 2
  • a

    Albin Groen

    06/17/2022, 6:49 AM
    Thanks for a fantastically well organized Prisma day yesterday! It was so fun to meet everyone in person. Props to the the Prisma team and all the presenters for great talks! Hope to meet you all again very soon 😊
    ❤️ 6
    prisma rainbow 4
  • a

    Aarav Shah

    06/17/2022, 12:00 PM
    @Nurul Is there any way to return relation model field with the help of groupBy
    ✅ 1
    n
    • 2
    • 9
  • a

    Aaron Waller

    06/17/2022, 6:16 PM
    I want to build a simple Home Feed like Instagram where the users sees new posts of the people he follows. So I try to findMany posts where the author of the post is followed by the user who’s requesting. Here is how I imagined it to work:
    Copy code
    return prisma.post.findMany({  
            where: {
              author: {
                followers: {
                  followerId: args.uid
                }
              } 
            }, 
            include: {
              author: { 
                include: {
                  followers: {
                    where: { 
                      followerId: args.uid
                    },
                  }
                }
              }
            }
          })
    But unfortunately it tells me `"Unknown arg
    followers
    in where.author.followers for type UserRelationFilter. Available args:",` More in thread
    a
    • 2
    • 4
  • d

    Debaucus

    06/17/2022, 9:20 PM
    Hey, how would I generate a full .sql migration file as if my db was brand new?
    👀 1
    n
    • 2
    • 4
  • d

    Debaucus

    06/17/2022, 9:21 PM
    Is the only way just to nuke the DB and redo the migration?
  • b

    Bernardo Trindade Abreu

    06/18/2022, 12:43 AM
    Hey guys, how’s it going ? Does anyone have an example of fetching data from an external source (i.e Github API) using Prisma for a rest API ?
    ✅ 1
    a
    n
    • 3
    • 4
  • m

    Moin Akhter

    06/18/2022, 11:51 AM
    Hello everyone i have a scnerio in project inwhich i have to upload large file to gcp bucket but i don't know how to resolve this problem my backend is on nodejs and frontend is on reactjs.Now how i can send chunks of a file and supload file to gcp bucket chunk by chunk and want a whole file uploaded url after every chunk get uploaded to gcp bucket successfully i also want a resumable functionality so that if internet connection lost or something happen bad it resume the file upload process i'm searching for 3 days but i'm not able to figure out any solution yet plz help.
    ✅ 1
    n
    • 2
    • 7
  • s

    Slackbot

    06/18/2022, 3:29 PM
    This message was deleted.
    👀 1
    n
    • 2
    • 1
  • i

    Ivan Lukianchuk

    06/18/2022, 6:20 PM
    I'm trying to implement the new data proxy connection string for my nextJs project and when I push to Vercel I get the error:
    Error validating datasource `db`: the URL must start with the protocol
    postgresql://
    or
    postgres://
    To use a URL with protocol
    prisma://
    the Data Proxy must be enabled via
    prisma generate --data-proxy
    .
    But as per the docs, I have added the line "PRISMA_GENERATE_DATAPROXY=true" into my .env.production, yet somehow it just seems ignored?
    ✅ 1
    h
    n
    • 3
    • 2
  • g

    Greg Renfro

    06/18/2022, 8:29 PM
    Question: I am trying to update column names. When I run yarn migrate dev, I get "Prisma Migrate could not create the shadow database. Please make sure the database user has permission to create databases. Read more about the shadow database (and workarounds) at https://pris.ly/d/migrate-shadow". This isn't my repo nor Heroku. My question is, how would the owner go about giving me access to update column names? Or is it something simpler?
    ✅ 1
    h
    n
    • 3
    • 7
  • p

    Prisma User

    06/18/2022, 9:45 PM
    Is there a way of pushing multiple items to an array? MongoDB supports it but couldn't find a way to do it in prisma?
    ✅ 1
    n
    • 2
    • 1
  • a

    Aaron Waller

    06/18/2022, 9:46 PM
    I want to build a simple Home Feed like Instagram where the users sees new posts of the people he follows. So I try to findMany posts where the author of the post is followed by the user who’s requesting. Here is how I imagined it to work:
    Copy code
    return prisma.post.findMany({   
            where: {
              author: {
                some: {
                  followers: { 
                    followerId: {
                      equals: args.userId
                     } 
                  }
                }
              }
            },
            include: {
              author: {   
                include: {
                  followers: {
                    include: {
                      follower: true
                    }
                  }
                }
              }
            }
          })
    But unfortunately it tells me "Unknown arg
    some
    in where.author.some" (Schema in thread)
    👀 1
    a
    • 2
    • 3
  • b

    Berian Chaiwa

    06/19/2022, 2:03 PM
    Never leaving Typescript! Thank you Prisma😄
    👍 2
    💚 1
    prisma rainbow 2
  • n

    Nditah Samweld

    06/19/2022, 3:02 PM
    How can I make an optional
    unique
    input field
    phone
    NULL
    instead of "`undefined`" for missing input. PostgreSQL guarantees uniqueness even for
    NULL
    fields but not for
    undefined
    values.
    Copy code
    model User {
      id                String          @id @default(cuid())
      email             String          @unique
      phone             String?         @unique
      @@map(name: "user")
    }
    👀 1
    h
    n
    • 3
    • 3
  • d

    Dog

    06/19/2022, 3:52 PM
    Hi! How do you guys store images in the database? I have this model here that seems perfect, but if I wanna use it in (for example) 10 different models I would have to make a relation for every model which seems kinda annoying. An alternative would be to just store something like "imageId" in the user model (or basically any model that needs to have an image) and since I'm using graphql it wouldn't be as much of an issue. Does my solution seem good?
    Copy code
    model Image {
      id Int @id @default(autoincrement())
    
      publicId String
      width    Int
      height   Int
      url      String
    
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
    }
    ✅ 1
    a
    h
    +2
    • 5
    • 11
  • m

    Moin Akhter

    06/19/2022, 6:09 PM
    Hello everyone as you may knew that gcp provides an ability to store files via presignedUrl my question is this can we upload chunk of files using this presignedUrl i am not able to clear about this anyone please?
    ✅ 1
    n
    • 2
    • 1
  • e

    Eric Fletcher

    06/19/2022, 8:26 PM
    Took 2 days, but I finally got the form submit to add to the database as it should!
    fast parrot 1
    ✅ 1
    👍 1
    n
    • 2
    • 1
  • t

    Tri Nguyen

    06/19/2022, 9:55 PM
    hi, anyone knows how to do conditional search condition? I.e if I only want to search for not null name if my variable is true
    Copy code
    prisma.people.findMany({ where: { what here? }})
    ✅ 1
    h
    n
    • 3
    • 2
1...587588589...637Latest