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

    מתן נחמני

    08/18/2022, 8:21 AM
    Hey hey, is there any way to orderBy string value for example with SQL
    Copy code
    .orderBy('user.state = "pending" ', 'DESC')
    First show users with state pending then the rest
    ✅ 1
    n
    • 2
    • 2
  • m

    MeetSnowmaker

    08/18/2022, 11:37 AM
    Hi all, Today I was upgrading to prisma 4.2.1 and encountered and error with the "orderByNulls" being unavalible
    Copy code
    Running generate... (Use --skip-generate to skip the generators)
    Error: Get DMMF: Schema parsing - Error while interacting with query-engine-node-api library
    Error code: P1012
    error: The preview feature "orderByNulls" is not known. Expected one of: filterJson, referentialIntegrity, mongoDb, interactiveTransactions, fullTextSearch, fullTextIndex,
    My other prject uses 4.1.0 at the moment and it works as intended. I did not find (or didnt look deep enough) any info on github or the release note about the feature being GA so i was wondering if It might be unintended.
    ✅ 1
    r
    • 2
    • 3
  • m

    Matheus Assis

    08/18/2022, 12:52 PM
    Is there an “Architecture” or a good practice in how to organize the graphql queries and fragments in a big app, and how to make sure it’s scalable? What do you guys usually go with, how do you do it? I tried having the queries in a separate folder instead of putting them in the same file as they’re used. And now it’s a mess. Some components use queries that belongs to other pages, etc etc.
    ✅ 1
    n
    • 2
    • 1
  • p

    Pedro Roque

    08/18/2022, 2:49 PM
    Hello I'm upgrading from prisma1 and I'm trying to get this relation to the new prisma4. Any ideias how this is now defined ? From prisma1: adultVersion: GarmentType @relation(name: "GarmentTypeAdultChild") childVersion: GarmentType @relation(name: "GarmentTypeAdultChild", link: TABLE)
    ✅ 1
    m
    n
    • 3
    • 2
  • a

    Adrien Wald

    08/18/2022, 2:54 PM
    eyo!
  • a

    Adrien Wald

    08/18/2022, 2:54 PM
    I'm trying to do a "batch get" operation over a model which has a compound id
  • a

    Adrien Wald

    08/18/2022, 2:55 PM
    To do a normal "get" I would use the compound id field on
    findUnique
  • a

    Adrien Wald

    08/18/2022, 2:56 PM
    For a model with a normal id, I would do
    findMany({ where: { id: { in: ['id1', 'id2'] } } })
    to do the "batch get"
  • a

    Adrien Wald

    08/18/2022, 2:57 PM
    But I'm not sure how to accomplish this with the compound id model
  • a

    Adrien Wald

    08/18/2022, 2:57 PM
    This looks like it might work, but I'm not sure about the efficency of it. Is this sound? Can it be improved on?
    Copy code
    await prisma.section.findMany({
          where: {
            OR: identifiers.map(({ resourceId, index }) => ({
              resourceId,
              index
            }))
          }
        })
    ✅ 1
    n
    • 2
    • 6
  • d

    Derrick Antaya

    08/18/2022, 3:02 PM
    hello, I'm using Prisma version 2.25 and Node version 16.17 and I randomly started getting an error yesterday, it was working fine the day before and I havn't updated anything.
    Copy code
    10:39:53 api-service | SyntaxError: Unexpected end of JSON input
    10:39:53 api-service |     at JSON.parse (<anonymous>)
    10:39:53 api-service |     at /Users/XXX/WorkSpace/XXX/node_modules/@prisma/client/runtime/index.js:27224:31
    10:39:53 api-service |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
    I have turned on the debug mode and the queries it seems to be generating look fine to me. Filling in the $1.. with the actual data and running the query directly on the DB returns expected results. Is there any thing else I can do to try and figure out what is causing this error?
    ✅ 1
    n
    • 2
    • 2
  • e

    Eduardo Maíllo Conesa

    08/18/2022, 3:54 PM
    Hola, pagination question. (nestjs + graphql + prisma) prisma query:
    Copy code
    async byConditionAndType(
        accountId: string,
        input: PatientDataLogGetInput,
        take?: number,
        cursor?: Prisma.DataLogWhereUniqueInput,
      ): Promise<DataLog[]> {
        return await this.prisma.dataLog.findMany({
          take,
          skip: 1,
          cursor,
          where: {
            accountId: accountId,
            condition: input.condition,
            logType: input.logType,
          },
          orderBy: {
            createdAt: 'desc',
          },
        });
      }
    The resolver:
    Copy code
    @Query(() => [OutputType])
      async getDataLogsByConditionAndType(
        @Args('input') input: DataLogGetInput,
        @Args('take') take?: number,
        @Args('cursor') cursor?: Prisma.PatientDataLogWhereUniqueInput,  
      ): Promise<DataLog[]> {
        const accountId = context.req.user?.accountId;
    
        try {
          return await this.dataLogService.byConditionAndType(accountId, input, take, cursor);
        } catch (e) {
          throw new ApolloError(e.message);
        }
      }
    The Error:
    Copy code
    Undefined type error. Make sure you are providing an explicit type for the "getDataLogsByConditionAndType" (parameter at index [3]) of the "DataLogResolver" class.
    What type should
    cursor
    be in the resolver endpoint to align with the method making the prisma query? The cursor is the id column if the table (uuidv4) bty, I am following this article (cursor pagination section) Thanks !!!
  • g

    guilherme

    08/18/2022, 4:09 PM
    Hey guys how everyone its doing? im having a weird issue with update
    Copy code
    return await this.alertRepository.update({
          where: {
            id,
          },
          data: {
            ...alertData,
            AlertAction: {
              updateMany: {
                data: AlertAction,
                where: {},
              },
            },
          },
        });
    ✅ 1
    h
    d
    n
    • 4
    • 14
  • g

    guilherme

    08/18/2022, 4:09 PM
    Copy code
    TypeError: value.map is not a function
        at tryInferArgs
  • g

    guilherme

    08/18/2022, 4:10 PM
    anyone with the same issue?
    👀 1
    n
    • 2
    • 10
  • j

    Justin F

    08/18/2022, 5:27 PM
    How do you hide the port number after the domain name using NGINX reverse proxy? Does anyone have a configuration that they could share? The problem is that I do not want people accessing port 8000 and want them to only access the domain name. What am I doing wrong? I am also using Prisma and Postgresql.
    ✅ 1
    n
    • 2
    • 2
  • j

    Justin F

    08/18/2022, 5:27 PM
    Copy code
    server {
        listen 80; # you can use 443 and letsencrypt to get SSL for free
        server_name 143.198.151.73; # domain name
        #access_log /var/log/somestuff/access.log; # mkdir dir first
        #error_log /var/log/somestuff/error.log error;
    
        # for public asset into _next directory
        location _next/ {
            alias /var/www/html/nextjs/.next/;
            expires 30d;
            access_log on;
    
        location / {
            # reverse proxy for next server
            proxy_pass <http://localhost:8000>; # your nextJs service and port
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
    
            # we need to remove this 404 handling
            # because next's _next folder and own handling
            # try_files $uri $uri/ =404;
            }
        }
    
    }
    h
    • 2
    • 1
  • k

    Kerem Kazan

    08/18/2022, 6:07 PM
    hi everyone, i had a question about prisma’s handling of CITEXT. it appears that there might be a recent regression that changes CITEXT default treatment from case-insensitive to case-sensitive. i’m happy to submit a pr to attempt to fix this, though i’d greatly appreciate a few pointers in terms of where i should be looking at
    ✅ 1
    n
    • 2
    • 5
  • a

    AdamRajch

    08/18/2022, 7:31 PM
    for prisma (postgres) json array, do i have to update with the full array or is there a way to "push" to the existing value
    ✅ 1
    n
    • 2
    • 1
  • w

    William GM

    08/19/2022, 2:15 AM
    Hello I have a table that has a compound
    primary key
    Copy code
    create table shipment_entry_detail (
    	shipment_entry_id uuid
    	shipment_entry_detail_id int
    	notes text
    );
    I also have a trigger that populates the
    shipment_entry_detail_id
    which is a sequence based on the rows of
    shipment_entry_id
    . It works perfectly but the prisma client expects the
    shipment_entry_detail_id
    to be populated by me, is there a way to tell prisma that I GOT IT? (😅)
    👀 1
    n
    a
    • 3
    • 5
  • s

    Samrith Shankar

    08/19/2022, 9:55 AM
    Hello! I am using Prisma with NestJS and PlanetScale, which is deployed to a Lambda. I have made the query engine binary available as a layer. The location of this layer is:
    Copy code
    /opt/prisma-binary
    I have set the above value as
    PRISMA_QUERY_ENGINE_BINARY
    . When I try to run a
    create
    request, I get the following error:
    Copy code
    Invalid `this.prisma.user.create()` invocation in
    /var/task/src/lambda.js:482655:43
    
      482652     throw new Error("Not found. Proceeding to create!");
      482653   }
      482654 } catch (_a4) {
    → 482655   user = await this.prisma.user.create(
      spawn /opt/prisma-binary EACCES
        at RequestHandler.request (/var/task/src/lambda.js:123709:19)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at async PrismaService._request (/var/task/src/lambda.js:124590:22)
        at async AuthService.verifyOTP (/var/task/src/lambda.js:482655:20) {
      code: 'EACCES',
      clientVersion: '3.15.2',
      meta: undefined
    }
    This works locally, but gives the above error on lambda. Any idea why?
    👀 1
    g
    g
    +2
    • 5
    • 16
  • l

    Lars Ivar Igesund

    08/19/2022, 10:59 AM
    Not sure if this is a general or prisma1 specific answer, but can I query for an object using the count of a connected item the critieria?
    ✅ 1
    n
    • 2
    • 1
  • l

    Lars Ivar Igesund

    08/19/2022, 10:59 AM
    I shoud like to query for objects that have zero items in a list
    ✅ 1
    n
    • 2
    • 3
  • b

    Bastien Etienne

    08/19/2022, 12:06 PM
    hello guys, need some advice, for who read this, for you what is best way to make an address table (use for many other tables) if you have some example for db design and prisma.
    g
    • 2
    • 2
  • r

    roshan karki

    08/19/2022, 2:23 PM
    hello everyone, does anyone here have migrated prisma1 cloud to local prisma1, my problem is, previous developer has not pushed latest code in github and schema is different then what it is in prisma1 cloud, am trying to introspect and get schema that is in prisma1 cloud, running, prisma1 introspect ask for various db settings, but prisma1 cloud has this url, and i am not sure what are the db setting on them, can someone help me out, (database.yml has this endpoint like : https://us1.prisma.sh/...../dev)
    👀 1
    n
    v
    • 3
    • 2
  • w

    Will Binette

    08/19/2022, 2:45 PM
    Does anyone's text editor get upset in TypeScript on your includes? Mine underlines it and give's this error:`The expected type comes from property 'include' which is declared here on type '{ where: { UserId: string; }; include: never; }'` The build runs and the query runs, but for some odd reason on everyone of my include calls it does this. I'm also using this within a tRPC router. Any suggestions?
    👀 1
    a
    v
    • 3
    • 2
  • m

    Marley

    08/19/2022, 2:53 PM
    Hey all, my startup is switching to use prisma for our ORM and loving it so far! Was curious to hear best practices for using Prisma Migrations on a Postgres DB (hosted in GCP) on a team of several engineers. Do you spin up and seed a new PG DB for each engineer? Then migrate to a shared stage/dev db and finally to prod? Any additional tools used? Are all db changes done through prisma (never directly on the db)? Great examples welcome!
    👀 1
    n
    v
    • 3
    • 2
  • s

    Slackbot

    08/19/2022, 3:03 PM
    This message was deleted.
    r
    • 2
    • 1
  • a

    Amol Patel

    08/19/2022, 4:06 PM
    Is there a way to run the Prisma Query Console locally? It seems its cloud only but figured I would ask since not explicitly called out on the website
    ✅ 1
    r
    • 2
    • 1
  • b

    Brayden Abick

    08/19/2022, 7:42 PM
    Hey all, running into a strange issue hoping to get a hand. Here is my schema.prisma model:
    Copy code
    model PairReading {
      pair         String   @db.VarChar
      time         DateTime @db.Timestamptz(6)
      reading0     Decimal  @db.Decimal
      reading1     Decimal  @db.Decimal
    }
    However, when I try to insert something like:
    Copy code
    {
            pair: '1542-AC',
            time: 2022-07-20T00:00:00.000Z,
            reading0: 999999961227775700000,
            reading1: 0.000007021900962402
    }
    I get the following error:
    Copy code
    code: 'P2033',
        clientVersion: '4.1.0',
        meta: {
          details: "Query parsing failure: A number used in the query does not fit into a 64 bit signed integer. Consider using `BigInt` as field type if you're trying to store large integers."
        }
    I am using Postgres, in my DB the reading0 and reading1 are numeric types and if I manually create a record with those values in that object above it inserts into the DB without any issues so the issue is coming from Prisma side. If I use other values with smaller numbers for readings, prisma doesnt throw anything and it inserts fine but for larger amounts like above it fails
    ✅ 1
    a
    • 2
    • 1
1...610611612...637Latest