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

    Kenneth Gitere

    06/10/2021, 6:51 AM
    Hi guys. I'd like to use Prism for my next project and wanted to know what backend framework (for a REST API) you'd recommend that works really well with TypeScript. Aside from Express (I'd like to try something new)
    r
    s
    +2
    • 5
    • 31
  • s

    Sascha Ormanns

    06/10/2021, 8:16 AM
    Hey there, I try to understand the concept behind Prisma Middleware. In the docs it says:
    Middlewares act as query-level lifecycle hooks, which allow you to perform an action before or after a query runs.
    When running a nested write or update query, is there any chance to get the result of all the queries/statements executed? Or am I on a prisma-client-function-level when in a Middleware and the result is the result returned from that client call? Something like
    Copy code
    prisma.user.create({
      data: {
        email: '<mailto:elsa@prisma.io|elsa@prisma.io>',
        name: 'Elsa Prisma',
        posts: {
          create: [{ title: 'How to make an omelette' }, { title: 'How to eat an omelette' }],
        },
      },
      include: {
        posts: true, // Include all posts in the returned object
      },
    })
    j
    • 2
    • 5
  • y

    Yazid Daoudi

    06/10/2021, 8:44 AM
    Hello all, I update prisma and now i've a lot problems like this : PANIC in libs/prisma-models/src/record.rs16130 Invalid coercion encountered: ConversionFailure("Float(BigDecimal(\"6000\"))", "Decimal") This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.
    r
    j
    • 3
    • 5
  • j

    jasci

    06/10/2021, 8:51 AM
    Hello, everybody, I’m trying to figure out the most performant way to write type resolvers, we can use either Prisma Fluent API or separate query: Here is the link to the issue with 2+ queries when fluent api is used. https://github.com/prisma/prisma/issues/1984
    Copy code
    // Option 1 - Separate Query
    export const Story = {
      tags: (_args, parent) =>
        db.tag.findMany({ where: { story: { id: parent.id } } })
    };
    
    // Option 2 - Fluent API
    export const Story = {
      tags: (_args, parent) =>
        db.story.findUnique({ where: { id: parent.id } }).tags()
    };
    But also docs states that
    findUnique
    queries are batched and it improves performance, so my thought was to use Fluent api if the separate query uses
    findMany
    like in the example above, but if we were to query single
    tag
    instead of
    tags
    (
    findUnique
    in both separate and fluent api queries) it’s better to use separate query. But regarding this issues people say that 1 query always outperform multiple queries, if that’s the case I don’t see any use cases where Fluent API is preferred. When would Fluent API be a better choice ? Thank you.
    d
    • 2
    • 3
  • b

    Benjamin Kroeger

    06/10/2021, 10:00 AM
    Hi there, I was wondering what everyone uses as REST Api layer with Prisma lately. I was going for NestJS - but that framework seems to rely heavily on decorators and thus reflection - which in-turn is only available with classes. So you need to manually create DTO and Entity classes implementing (partial) types from PrismaClient. NestJS uses class-validator and class-transformer to validate HTTP request payload and to filter properties from HTTP response bodies. Even worse - class-transformer only works on instances of a class... and PrismaClient returns plain-old JavaScript objects (which I actually like a lot) It also requires classes to generate Swagger documentation (because of Reflection again) Looking for any kind of response here 😀
    k
    o
    +3
    • 6
    • 8
  • l

    Levi Lawliet

    06/10/2021, 10:24 AM
    Hi, me again Lol, So I have this query to update a record something like this, I want to ensure that only the user who created it, can authorize the edit.
    r
    • 2
    • 8
  • p

    Paul G

    06/10/2021, 11:12 AM
    does anyone know what the url is to login to twistlock compute self hosted locally ?
    j
    • 2
    • 1
  • d

    Dev__

    06/10/2021, 2:17 PM
    hello I am trying to sort by relation inside an
    include
    but its not working. the relation sort does work at the
    orderBy
    Copy code
    where,
    include: {
    	buyerGroupDescriptions: {
    		where: {
    			languageId
    		},
    		orderBy: {
    			name: order // 'asc' or 'desc', not working
    		}
    	}
    }
    orderBy: {} // working
    r
    • 2
    • 10
  • j

    jasci

    06/10/2021, 3:55 PM
    Hello everybody, does prisma2 have an analog of
    $exists
    property from prisma1?
    r
    • 2
    • 1
  • d

    drongo

    06/10/2021, 4:05 PM
    Is there some way I can use Prisma, Typescript and graphQL without having to write the schema 3 times?
    p
    r
    a
    • 4
    • 12
  • i

    Indxgo

    06/10/2021, 4:50 PM
    if i change a model name in schema.prisma, how do i get it to update? I tried to restart my nextjs app and everything but it says undefined
    r
    j
    • 3
    • 8
  • b

    Benjamin Klotz

    06/10/2021, 5:14 PM
    Hi, is there a way to log queries in a way where it can access the request/parent context? We are using https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#on so far, but maybe I missed something obvious. Query logging with https://github.com/iamolegga/nestjs-pino seems to be missing request context and therefore the request id, also using datadog for tracing seems to not being able to correlate query traces with request traces. I assume this is due to the way how prisma is designed (with its separate query engine), is this something which can be improved once using n-api mode?
    r
    • 2
    • 5
  • a

    ali

    06/10/2021, 5:25 PM
    Hi, I had a question regarding transactions. I am observing the following:
    Copy code
    // WORKS - (rollback of write2 happens if write1 fails)
    const write1 = prisma.user.create()
    const write2 = prisma.post.create()
    await prisma.$transaction([write1, write2])
    
    
    // BROKEN? - (write2 is NOT rolled back if write1 fails)
    const write1 = prisma.user.create()
    const write2 = prisma.post.create()
    write2.then(() => console.log('something happened'))
    await prisma.$transaction([write1, write2])
    Is this behavior expected?
    d
    j
    r
    • 4
    • 5
  • k

    kfredericks

    06/10/2021, 7:15 PM
    Okay, I finally determined the source of the model types, HOWEVER, can someone describe why the type exports are ES6 syntax when everything else in Prisma is commonJS?
  • t

    Tim Griffin

    06/10/2021, 7:27 PM
    Hi folks, using prisma2 and postgres, I'm finding if I use the
    @db.ByteA
    type on one of my fields and save a
    buffer
    to it with length < 8192, the resulting buffer when I request it from the database again is 8192. Larger buffers I've saved and successfully retrieved from the database
    r
    • 2
    • 2
  • j

    jasci

    06/10/2021, 7:55 PM
    Hello everybody, does prismaClient generate type for the client itself (like
    PrismaClientType
    ) ? Also is there some info in the doc about the generated files for prisma client I can read ?
    r
    • 2
    • 3
  • d

    Dev__

    06/11/2021, 6:42 AM
    is there a way to generate all types for a client, like graphql code generator has?
    т
    r
    • 3
    • 8
  • u

    user

    06/11/2021, 9:48 AM
    Prisma Day Is Coming Soon!!

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

    Prisma Day 2021 is happening on June 29-30th and is entirely online! Make sure you sign up at https://prisma.io/day 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
    fast parrot 4
  • w

    Wuxxy

    06/11/2021, 11:05 AM
    This isn't a completely prisma error but basically, my prisma won't connect to my postgressql server if I put the server IP instead of localhost - it's not that it cannot connect, it just fails to authenticate.
  • w

    Wuxxy

    06/11/2021, 11:06 AM
    I'm doing
    npx prisma db push
    btw to test this - and prisma won't connect when I use server IP when using the client itself
  • w

    Wuxxy

    06/11/2021, 11:17 AM
    Again, I should mention this isn't something to do with remote connection - I allowed remote connection, this is something to do with authentication
  • w

    Wuxxy

    06/11/2021, 11:17 AM
    Error: P1010: User
    <username>
    was denied access on the database
    <databasename>.public
    j
    • 2
    • 27
  • n

    Nichita Z

    06/11/2021, 11:40 AM
    Hello all! Got a quick question regarding the ‘selectRelationCount’ feature in prisma
  • n

    Nichita Z

    06/11/2021, 11:41 AM
    I’d like to filter the counted objects (in my case, only count comments for a post if the comment was approved). Is that supported in any way?
    r
    • 2
    • 3
  • n

    Nic Luciano

    06/11/2021, 1:01 PM
    hi all, thank you for this channel. when i try to use the
    filterJson
    preview feature to query where a path is
    undefined
    , i get
    A JSON path cannot be set without a scalar filter.
    at runtime, despite the
    InputJsonValue
    type allowing undefined. the json field is nullable, and has a default set to
    {}
    in prisma. am i doing something wrong? or is support still limited? thank you. 🙂
    r
    • 2
    • 9
  • j

    Julian

    06/11/2021, 2:18 PM
    Hey is it possible in Prisma to generate statistics data? Such as total users per month, new users per month, etc.
    r
    • 2
    • 2
  • l

    Levi Lawliet

    06/11/2021, 3:46 PM
    Hi, I wanted to if it is possible to run heroku cli command for resetting postgresql addon db as part of deployment Release phase? I read the docs and still had some doubts
    • 1
    • 1
  • i

    Indxgo

    06/11/2021, 4:43 PM
    Hi, why can I not use
    Copy code
    await prisma.account
          .findFirst({
            where: {
              id: user.id,
              authorization: user.authorization,
            },
          });
    but I can use
    Copy code
    await prisma.account
          .findMany({
            where: {
              id: user.id,
              authorization: user.authorization,
            },
          });
    If I use the first example I get an error:
    Copy code
    Argument where of type AccountWhereUniqueInput needs exactly one argument, but you provided id and authorization. Please choose one. Available args:
    Nevermind, the second example was working yesterday night but now both give the error, any help?
    r
    • 2
    • 1
  • i

    Indxgo

    06/11/2021, 9:26 PM
    Hi, can someone please help me with this error:
    Copy code
    Argument where of type AccountWhereUniqueInput needs exactly one argument, but you provided id and authorization. Please choose one. Available args:
    I don't know how to fix it
    j
    s
    • 3
    • 45
  • m

    Manthan Mallikarjun

    06/12/2021, 2:52 AM
    Hey, does anyone know if Prisma has generic types I can use?
1...442443444...637Latest