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

    Aaron Waller

    12/27/2021, 12:11 PM
    I tried it like this:
    Copy code
    Mutation: {
        createPost: (parent, args) => {
          return prisma.content.create({ 
            postinput: {
                name: args.name,
                content: args.content
              
            }
            
          })
        }
      }
    But it is not working and giving me the following error: Unknown arg
    postinput
    in postinput for type Content. Did you mean
    select
    ?\nArgument data is missing.
  • a

    Aaron Waller

    12/27/2021, 12:14 PM
    When I get rid of the “CreatePostInput” input type and design the Mutation like this:
    Copy code
    type Mutation {
        createPost(name: String, content: String): Post!
      }
    and my resolver like this:
    Copy code
    Mutation: {
        createPost: (parent, args) => {
          return prisma.content.create({ 
            data: {
                name: args.name,
                content: args.content
              
            }
            
          })
        }
      }
    it is working fine The problem is I want to keep the PostCreateInput input to add a lot of fields there
    m
    • 2
    • 1
  • j

    Juan Carlos Blanco Delgado

    12/27/2021, 12:35 PM
    Hey guys, Which is the best approach to apply permissions and authentication to prisma?
  • j

    Joonatan

    12/27/2021, 1:15 PM
    Hi! Is there a possibility to multiply two fields with each other in findMany in order to fetch one additional field with the multiplied value? Or should I use raw query if I want to achieve this?
  • d

    Diego Serrano

    12/27/2021, 8:04 PM
    Hello 🙂
  • d

    Diego Serrano

    12/27/2021, 8:05 PM
    Could someone help me understand tradeoffs of not using GIS for location data? I really want to use Prisma, but this is an important requirement in a platform I am working on Was wondering if storing latitude and longitude would be enough
    j
    • 2
    • 5
  • j

    joao.santos

    12/28/2021, 9:28 AM
    Hi guys, is there anyway to enforce model names conventions in prisma.schema? with eslint or something?
  • h

    hj yuiyui

    12/28/2021, 10:20 AM
    Hi guys it is possible to do something like that, i want the function to execute first prisma.pageview.create then update
    export async function savePageView(website_id, session_id, url, referrer) {
     
    const ref = new Referer(referrer);
     
    return runQuery(
       
    prisma.pageview.create({
         
    data: {
           
    website_id,
           
    session_id,
           
    url: url?.substr(0, URL_LENGTH),
           
    referrer: (await getRef(referrer)) //put referrer "direct" if parameters in function is empty,
           
    referrer_group: ref.referer ? ref.referer : ref.uri.hostname,
           
    referrer_medium: ref.medium,
         
    },
       
    }),
       
    prisma.pageview.update({
         
    where: {
           
    referrer: "direct",
         
    },
         
    data: {
           
    referrer_group: "Visites directes",
         
    },
       
    })
     
    );
    }
  • h

    hj yuiyui

    12/28/2021, 11:43 AM
    Why guys when i run this (pic) it returns me this error : PrismaClientValidationError: Unknown arg
    referrer
    in where.referrer for type pageviewWhereUniqueInput. Did you mean
    select
    ?"
    m
    • 2
    • 9
  • γ

    Γιώργος Κραχτόπουλος

    12/28/2021, 12:30 PM
    Has anyone worked with a custom implementation of Soft-Delete functionality? How can I filter in middleware relations like
    where: { deletedAt: null }
    ? Middleware is only called once on
    findUnique()
    call, but I want a middleware to run on every query operation. The following:
    Copy code
    await prisma.cart.findFirst({
      where: { id: 107 },
      include: { foods: true } },
    });
    will call middleware
    prisma.$use()
    only once, and not for the DB query when fetching the relation
    foods
    t
    • 2
    • 5
  • n

    Nischal

    12/28/2021, 1:25 PM
    is there way i can get time series data in prisma ?
  • m

    Mattèo Gauthier

    12/28/2021, 1:54 PM
    Hey does someone know how to programmatically create users and login to these with next-auth ? (I got this error
    OAuthAccountNotLinked
    from next-auth due to prisma seed)
  • j

    James

    12/28/2021, 4:57 PM
    Any thoughts on the best way to handle something similar to postgres time data type. I need to store the start time for a shift without any concept of date. I was thinking maybe just a string field
  • l

    lawjolla

    12/28/2021, 5:56 PM
    Prisma 1 user transitioning to Prisma 2/3 with a basic question. How do I get the scalar model types from Prisma? E.g. in Prisma 1, it's...
    Copy code
    import { Deal } from "prisma1/generated/prisma-ts"
    
    const calculateDealProfit = (deal: Deal): number => {
     ....
    }
  • a

    Anony Mous

    12/28/2021, 8:24 PM
    Uhh
  • a

    Anony Mous

    12/28/2021, 8:24 PM
    I encountered a bug
  • a

    Anony Mous

    12/28/2021, 8:24 PM
    prisma will not name capatalized models correctly in the generated class
  • a

    Anony Mous

    12/28/2021, 8:24 PM
    ie
  • a

    Anony Mous

    12/28/2021, 8:24 PM
    Note -> note
  • a

    Anony Mous

    12/28/2021, 8:24 PM
    this is especially annoying when dealing with acronyms...
  • s

    Spencer Kifell

    12/28/2021, 9:22 PM
    Anyone know how to deal with deleting data from a table which contains a self referencing foreign key with prisma? Normally I would delete the orphaned data first, but doesn't seem to be working?
  • s

    Spencer Kifell

    12/28/2021, 9:26 PM
    Referential actions?
  • c

    Chris Tsongas

    12/29/2021, 5:07 AM
    I just started trying out the fluent API and I've noticed that if the last call doesn't find any records, the query returns null instead of an empty array like you would get from
    findMany()
    which is a bummer because if I just return that to Apollo it throws an error like
    "message": "Cannot return null for non-nullable field Query.employeeNotes."
    . Is this a known issue that will get fixed? In the meantime as a workaround I have to await the result of the query and use the nullish coalescing operator to return an empty array if there are no results:
    Copy code
    async getEmployeeNotes(employeeId: string): Promise<EmployeeNote[]> {
        return (
          (await prisma.employee
            .findUnique({
              where: {
                id: employeeId,
              },
            })
            .employeeNotes()) ?? []
        )
      },
  • c

    Chris Tsongas

    12/29/2021, 5:32 AM
    This syntax seems more straightforward:
    Copy code
    getEmployeeNotes(employeeId: string): Promise<EmployeeNote[]> {
        return prisma.employeeNote.findMany({
          where: {
            employeeId,
          },
        })
      },
    I'm just not sure which is better performance-wise in terms of the number of queries created and the GraphQL n+1 problem which I don't understand yet but plan to read up on.
  • j

    Julien Goux

    12/29/2021, 1:25 PM
    Hello team, is there any progress on this issue ? https://github.com/prisma/prisma/issues/8989
  • j

    Julien Goux

    12/29/2021, 1:27 PM
    Our CI time almost doubled because we can’t run jest in one go anymore. We have to run it in batch and we’re paying jest’s bootstraping the environment cost for every batch 😅
    n
    • 2
    • 9
  • j

    Jakub Figlak

    12/29/2021, 1:47 PM
    How can I catch this kind of error?
    Copy code
    Unknown arg `country` in data.country for type RegionUncheckedUpdateInput. Did you mean `countryId`? Available args:
    type RegionUncheckedUpdateInput {
      id?: String | StringFieldUpdateOperationsInput
      name?: String | StringFieldUpdateOperationsInput
      createdAt?: DateTime | DateTimeFieldUpdateOperationsInput
      updatedAt?: DateTime | DateTimeFieldUpdateOperationsInput
      countryId?: String | StringFieldUpdateOperationsInput
    }
    This is probably not
    PrismaClientKnownRequestError
    cause it's missing my nest filter.
    m
    • 2
    • 13
  • s

    Shmuel

    12/29/2021, 2:17 PM
    Hi, I'm having issues using a many-to-many self-relation similar to the example used in the Prisma docs. I'm running into an error when creating a record along with its relation. The error I'm getting is this.
    Copy code
    PrismaClientValidationError: Unknown arg `follower` in data.followers.create.0.follower for type FollowsCreateWithoutFollowerInput. Did you mean `following`?
     Argument following for data.followers.create.0.following is missing.
    I posted this question with more details on stackoverflow https://stackoverflow.com/questions/70520589/prisma-many-to-many-self-relation-error-due-to-relation-and-generated-type-inpu If anyone has any ideas I would greatly appreciate it. Thanks in advance.
    m
    y
    • 3
    • 17
  • w

    Winter

    12/29/2021, 2:29 PM
    Hi, has anyone got any (recent) tips for pairing Prisma with a storage solution? I'm looking to store audio files generated via a text-to-speech API. The files need to be retrievable by the user, once generated.
  • b

    Barnaby

    12/29/2021, 2:30 PM
    The typical go-to for that is S3 or an S3-compatible object storage service (or self hosted Minio)
1...527528529...637Latest