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

    Akash

    02/17/2021, 5:17 AM
    Hi, After upgrading to 2.17 I am suddenly seeing a lot of errors in node_modules/.prisma/client/index.d.ts and my nestjs build step is failing. Here is a sample log. I am not sure what's happening here since I even downgraded back to 2.16 and deleted node_modules and did a fresh rebuild but even then these errors remain. Don't know if it's something related to Prisma or just at my end.
    r
    j
    t
    • 4
    • 18
  • p

    Pascal Sthamer

    02/18/2021, 1:33 PM
    I have a question regarding transactions. Will the following work and be properly rolled back when any query fails?
    Copy code
    const queries = []
    
    for (const somevar of somearray) {
      const params = await someAsyncFunc(somevar)
      queries.push(prisma.someQuery(optsWithParams))
    }
    
    await prisma.$transaction(queries)
    The thing Im unsure about is that query 1 might be finished before calling prisma.$transaction because there are async operations required to generate the other queries.
    ✅ 1
    r
    • 2
    • 8
  • t

    Tanmay Naik

    02/22/2021, 6:59 AM
    I'm suddenly getting this error and similar ones all over my api. It was working fine until yesterday. How do I debug? I changed the types in the questionnaire table from int to string and it worked fine yesterday
    r
    • 2
    • 4
  • a

    Anders

    03/01/2021, 4:47 PM
    I am getting an error for the following prisma updateMany query, not sure if I am formatting it right. I want to update multiple rows by there ID.
    Copy code
    const updatedPostCount = await prisma.formInput.updateMany({
        where: {
          id: [
            "49523f75-9ec5-471f-999a-62b8097cabcc",
            "51272b87-9592-4121-83f8-a1471abcc540",
          ],
        },
        data: { name: "test mass" },
      });
    I get the following error
    Copy code
    Argument id: Got invalid value 
    [
      '49523f75-9ec5-471f-999a-62b8097cabcc',
      '51272b87-9592-4121-83f8-a1471abcc540'
    ]
    on prisma.updateManyFormInput. Provided List<UUID>, expected StringFilter or String.
    type StringFilter {
      equals?: String
      in?: List<String>
      notIn?: List<String>
      lt?: String
      lte?: String
      gt?: String
      gte?: String
      contains?: String
      startsWith?: String
      endsWith?: String
      not?: String | NestedStringFilter
    }
    any help would be great
    b
    • 2
    • 16
  • a

    Anders

    03/01/2021, 4:49 PM
    oh I see I should post in github I will do that, oops
  • s

    Shreyas Sreenivas

    03/02/2021, 9:47 PM
    Hi, I’ve recently been working on optimizing a GraphQL API and the age old n+1 problem and I came across this

    video▾

    to see how Prisma does it. In the video, Tim uses Prisma’s Fluent API to fetch the related fields and he mentions that Prisma makes use of the dataloader pattern. But, based on previous testing of my API, in which I don’t use the Fluent API, the requests weren’t batched. I then converted my queries to use the Fluent API, and voila, the requests were now batched! However, there doesn’t seem to be a mention of this anywhere in the docs. It’s also mentioned that the main difference between the two is that Fluent API makes two separate requests, which could seem inefficient at first… i.e. until you realise that it batches requests (which is awesome!) In my opinion, a section could be added to differentiate between using the Fluent API and the general API and also give a brief intro to the dataloader pattern and explain how Fluent API batches requests. Thoughts?
    👍 1
    👍🏾 1
    n
    r
    m
    • 4
    • 6
  • s

    sakulstra

    03/05/2021, 3:24 PM
    Hello, i'm just playing around with prisma and therefore
    createMany
    and was wondering if we might see the improvements proposed in https://github.com/prisma/prisma/issues/5437#issuecomment-772692381 are being considered to be pulled into the experimental mode? &/or as long as we don't how are you guys working around that issue 🤔 I got a cronjob batch upserting 50k docs and doing this sequentially seems like a rather bad idea - especially as i'm on serverless with function timeout-limits. I've now chunked it and process it with multiple lambdas, but that's a quite connection heavy approach. Is $rawQuery the way to go?
    r
    • 2
    • 4
  • j

    JY

    03/15/2021, 6:10 AM
    I didn’t want to notify every one in the thread but I would love to know what the status of this issue is https://github.com/prisma/prisma/issues/5040 It has been a while since the last update and it would be really great to have it implemented 😄
    t
    • 2
    • 2
  • t

    Tanmay Naik

    03/15/2021, 10:12 AM
    How to do an exists query in Prisma with findMany where?
    r
    • 2
    • 2
  • m

    maxweld

    03/16/2021, 1:36 PM
    Hi. Although I could not attend the live transmission, I watched the recent Prisma Chat - All about Transactions that took place last week. This left me perplexed and with a few questions. I am trying to decide the architecture of a proposed system. It needs to scale, as it will have an estimated user population of 700k, and a potential transaction rate of >100k per hour peak. The integrity of the data will be paramount, as the system will handle financial transactions amongst its mix. I want therefore to use the built in transaction integrity features of the underlying database as far as possible, and recognise that I may need to choose a database provider that supports my requirements, such as MySQL. I want to be able to Begin a Transaction and Commit a transaction, and I want to know that at the end of the transaction my data is safely stored in the database, and if the application falls over or the database server collapses, that I can rely upon the database recovery procedures to rebuild the database and restart with my committed data intact. At the same time, if something fails after my transaction has started, but before it commits the changes, then I want the database to ensure that the data changes made during the incomplete transaction are rolled back, as though the transaction had never started. So my question to the Prisma team is how is Prisma managing the transactions: Is it using the underlying Databases transaction capabilities, if available, or does it manage the transaction itself? Are the transaction capabilities dependent upon the underlying provider? Does the 'lowest common denominator' issue mean that Prisma must manage the transaction integrity. As a relational database programmer and administrator for many years, I trust in the DBMS to manage the transactions. I understand the implications for locking and the strategies for reducing contention. While I very much like syntax provided by Prisma to query and manipulate the data, I am concerned by any possibility that it will put a layer between the developers code and the database transaction support. Thanks in advance
    b
    m
    n
    • 4
    • 4
  • b

    Ben

    03/22/2021, 11:24 PM
    Hi, has anyone been able to get prisma client working on M1 Macs? Trying to build a prototype this week and would like to use prisma (as it’s built into the boiletplate) but I can’t get client to work at all.
    m
    • 2
    • 1
  • j

    Jeff Clark

    04/04/2021, 3:54 PM
    Has anyone experienced a problem with
    $transaction
    where you get a runtime error like this?
    Copy code
    TypeError: Cannot assign to read only property '_transactionId' of object '#<NewPrismaClient>'
    I have been trying to puzzle this out for 3 straight days and am at my wits end. I also asked yesterday on GH Discussions with more details: https://github.com/prisma/prisma/discussions/6395
  • s

    Shreyas Sreenivas

    04/06/2021, 7:10 PM
    Is it possible to count the number of relationships when using the fluent API? Or is there a way to fluently get the count of relations while batching the queries to get the count?
    r
    • 2
    • 1
  • b

    Ben Ezard

    04/12/2021, 10:43 PM
    Is there a way to run migrations from code? I'm trying to run
    npx prisma migrate deploy
    within a Jest global setup script, and it works locally but fails when running in GitHub Actions CI, saying
    Copy code
    /usr/bin/env: 'node': No such file or directory
    Command failed: npx prisma migrate deploy
    No idea why it's happening since Node is definitely in the path, but being able to run migrations from code (e.g.
    prismaClient.runMigrations()
    ) would still be super useful for test setup I imagine it'd probably be necessary to specify the path to the Prisma schema/migrations directory in case the current working directory doesn't include them
    r
    • 2
    • 2
  • n

    Niko Guerra

    04/15/2021, 1:24 AM
    Haven't been able to find any resources explaining what the error could be stemming from when this error is received, does anyone have any links to resources?
    Copy code
    Invalid response data: the query result was required, but an empty Object((Weak)) was returned instead.
    This is when I'm executing
    .create()
    statements
    r
    r
    • 3
    • 2
  • r

    Rintsi

    04/16/2021, 3:51 PM
    What is the best way to debug PostgreSQL error "The provided value for the column is too long for the column's type. Column: (not available)"?
    j
    • 2
    • 26
  • n

    Nick

    04/16/2021, 5:34 PM
    Hi all. I’m a huge fan of Prisma—great work! Absolutely love it. I’m using Prisma along with Apollo Client/Server in a Next.js app with a GraphQL API and a Postgres db. I’m using apollo-micro-server to integrate with Next.js and have the Prisma GraphQL Playground running at
    localhost:3000/api/graphql
    to test my queries before implementing them. I’m using my Prisma schema definitions inside of my Apollo Server typeDefs/resolvers, and am running version
    2.21.2
    of @prisma/client and version
    2.22.2
    of apollo-server-micro. I’m currently unable to get the new relation’s count feature working (meaning, the
    _count
    option doesn’t appear in my GraphQL Playground queries), and have tried virtually every permutation I can think of. When I’m inside of a React component and am updating my gql query, the
    _count
    option will autocomplete as I type, as if it’s being recognized, but upon saving my changes, the page breaks. It won’t autocomplete when I’m inside my GraphQL playground, however. I have enabled the
    selectRelationCount
    option in the generator portion of my
    schema.prisma
    as the docs instruct, and ran
    yarn prisma generate
    to ensure that my new client data is updated. Here’s a simplified example with a User type that has many Posts: typeDefs
    Copy code
    type User {
      id: Int!
      email: String!
      posts: [Post]
    }
    
    type Post {
      id: Int!
      title: String!
      user: [User]
    }
    I can’t figure out why the following resolver won’t allow me to access the
    _count
    data in my GraphQL Playground queries or within a gql query in a React component: resolvers
    Copy code
    allUsers: () => {
      return prisma.user.findMany({
        include: {
          _count: {
            select: {
              posts: true,
            },
          },
          posts: true,
        },
    
      });
    },
    This is my first time integrating Prisma with Apollo/Next.js so please let me know if I’m overlooking something super simple. Thanks!
    ✅ 1
    r
    a
    • 3
    • 4
  • m

    Mitchell Romney

    04/18/2021, 4:18 PM
    Question: What is the most efficient way to individually update thousands of records regularly? Currently I can only see the ability to bulk update multiple records to the same field values, or just do 1 query per record.
  • r

    Rintsi

    04/19/2021, 9:22 AM
    Is it really so that I cannot use CIDR column together with PostgreSQL and Prisma?
    Copy code
    ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: FromSql(9), cause: Some(WrongType { postgres: Cidr, rust: "core::option::Option<std::net::ip::IpAddr>" }) }) })
    a
    • 2
    • 14
  • t

    Tanmay Naik

    04/28/2021, 4:29 AM
    Hello, how do I avoid resetting the database on production? Currently the resetting is not under my control, it resets the database sometimes and sometimes it doesn't.
    j
    • 2
    • 1
  • r

    Rintsi

    04/29/2021, 8:02 AM
    How do I make a field nullable? I mean that I have a simple relation for a table that contains items related to an asset. If the table is empty I get an error "Cannot return null for non-nullable field". So I have a
    Copy code
    @ResolveField()
    async items(@Parent() asset: Asset, @Args('first') first: number) {
        return this.prisma.asset.findUnique({ where: { id: asset.id } }).items({ take: first });
    }
    o
    • 2
    • 7
  • d

    Dan M

    05/04/2021, 8:35 PM
    Anybody having issues with the new`_count` feature? I'm getting red squiggles and this error:
    Copy code
    Type '{ _count: { select: { initialLadderAppearances: true; }; }; }' is not assignable to type 'MemberInclude'.
    Object literal may only specify known properties, and '_count' does not exist in type 'MemberInclude'.ts(2322)
    I just verified that I generated my Prisma client using 2.22.0, and I reloaded VSCode.
    _count
    doesn't seem to exist anywhere 🤷‍♂️🤷‍♂️🤷‍♂️ Here's the relevant code snippet:
    r
    • 2
    • 11
  • l

    Liam Potter

    05/06/2021, 9:52 AM
    Is there a way for me to run
    npx prisma db push --preview-feature --force-reset
    from the js PrismaClient? I want to use it to clear my database after I run tests. I suppose I can always use spawn to run the command but if there is a js way to achieve the same thing I’d prefer that.
    d
    r
    • 3
    • 3
  • s

    sakulstra

    05/12/2021, 2:27 PM
    Playing around with the early access of mongodb - i there a way to directly access the
    MongoClient
    via prisma client for doing things like complex aggregations or bulks?
    j
    • 2
    • 1
  • k

    Kerem Kazan

    05/12/2021, 3:26 PM
    Hi everyone, i need help with custom typings. Is there a recommended way of narrowing the generated model types? Here’s what it would look like:
    Copy code
    model Member {
      id    Int    @id @default(autoincrement())
      email Email
    }
    the
    Email
    type would be coming from typescript. If modifying the schema like above is not possible/recommended, is it at least possible to have this type appear on the generated client types? i’d want all prisma methods on the
    Member
    type to expect the email field to be of type
    Email
    , not just
    string
    r
    • 2
    • 4
  • a

    afeurra

    05/14/2021, 7:37 AM
    hey guys! I'm playing around with prisma and typescript and I'm stuck on an issue. I declared a column as Json (using postgres) but I cannot find a way to read it from db
    Copy code
    const room = await prisma.room.findUnique({ where: { id: roomId } })
                room.messages // what type should I declare this in order to edit it?!
    r
    • 2
    • 3
  • j

    James

    05/15/2021, 7:58 PM
    Is anyone successfully using PrismaClient with pnpm? If I type
    Copy code
    rm -rf node_modules/ ; pnpm i
    And restart the TS server, I loose all my type info, it becomes type 'any'
    Copy code
    rm -rf node_modules/ ; yarn
    And restart the TS server, and I get my type info back
  • l

    Liam Potter

    06/03/2021, 2:17 PM
    db push
    is all of a sudden giving me this error
    Copy code
    Response: Database `mydb-test.public` does not exist on the database server at `localhost:5432`.
    this used to be fine, the docs state
    db push
    will create the database if the database does not exist, so I’m not sure why this is now happening?
  • l

    Liam Potter

    06/03/2021, 2:19 PM
    If I manually create the database the push happens fine and my tests run
    r
    • 2
    • 6
  • p

    Parker Lawrence

    06/03/2021, 4:33 PM
    Is there a way to compose a type for a specific combination of
    includes
    ? For example, suppose I have a query like this:
    Copy code
    prisma.user.findUnique({
      where: { id },
      include: {
        post: true
      },
    });
    and I want to create a type for the result leveraging the Prisma generated types. something along the lines of this (I’ve just made up the
    Includes
    helper tho):
    Copy code
    import { User, Post } from '.prisma/client';
    type UserWithPosts = Include<User, Post>;
    👍 1
    👀 1
    r
    • 2
    • 3
1...789...23Latest