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

    Mischa

    09/29/2021, 3:44 PM
    Trying out prisma 3, it’s not running properly in my lambda function/layer setup. I get the error
    ENOENT: no such file or directory, open '/var/task/schema.prisma'
    Can I at least tell it what path my
    schema.prisma
    file is at somehow? I couldn’t find anything in the docs I commented on https://github.com/prisma/prisma/issues/9435
  • p

    Phong Ho

    09/30/2021, 6:59 AM
    Hello, @Ryan We are running 2 apps with prisma 2. in frontend side it looks like every apis response correctly, but as you can see, Some queries still remain and piles up until there is no connection slot available anymore and making the app crash. Do you have any idea?
    r
    • 2
    • 2
  • m

    Mischa

    09/30/2021, 7:04 AM
    anyone try using a lazy getter for accessing
    PrismaClient
    ? in prisma 3 constructing the client now tries to load the schema.prisma file which I don’t have in my lambda functions that don’t use prisma (but do happen to import the file that constructs the client)
  • m

    Mischa

    09/30/2021, 2:26 PM
    I just wanted to provide some timing info for running prisma 3.1.1 on a lambda function with 1024MB RAM and DEBUG=* I requested a simple function that does a single query to a table with 1 row. First as a cold start and then a second warm request. Looks like on cold start, initializing prisma took ~0.75s (14:55.075Z - 14:54.321Z) On a warm lambda the entire request took 923ms to run
    prisma.tenant.findMany()
    which seems like a while. It's a lambda function in a VPC talking to an aurora serverless pg database, I would expect it to be a bit faster than that. Just wanted to share in case this is useful information for someone.
    lambda performance timing with prisma 3.txt
  • m

    Mischa

    09/30/2021, 4:08 PM
    any way to instrument prisma with xray? maybe using something like aws-xray-sdk-postgres?
  • k

    koufatzis

    10/02/2021, 3:02 PM
    Hello is it possible in Prisma schema to define (numeric)
    CHECK
    constraints ?
    r
    • 2
    • 4
  • m

    Mischa

    10/03/2021, 10:23 AM
    What does this error mean? I’m using prisma-appsync with ESM and my AWS lambda layer “Issue parsing prismaClientModels from auto-injected environment variable
    PRISMA_APPSYNC_GENERATED_CONFIG
    .” Prisma client loads just fine for all my other lambdas, only prisma-appsync seems to have the problem
  • r

    Ridhwaan Shakeel

    10/03/2021, 9:03 PM
    is it possible to do nested connectOrCreate? for example
    Copy code
    const album = {
            ...result,
            songs: {
              connectOrCreate: result.songs.map(s => ({
                create: {
                    ...s,
                    artists: {
                        connectOrCreate: s.artists.map(a => ({
                        create: a,
                        where: { spotify_id: a.spotify_id }
                    }))
                },
                where: { spotify_id: s.spotify_id }
              }))
            }
          }
    
    schema:
    model Album {
       artists					Artist[]
       songs					Song[]
    }
    
    model Artist {
        albums    				Album[]
    	songs					Song[]
    }
    
    model Song {
       album    				Album    	@relation(fields: [album_spotify_id], references: [spotify_id], onDelete: Cascade)
    	artists					Artist[]
    }
    r
    • 2
    • 1
  • j

    james tan

    10/04/2021, 6:30 AM
    hi, ,anyone encountering "Field does not exist on enclosing type" even if the field exists?
    r
    • 2
    • 18
  • d

    Danny Nemer

    10/05/2021, 3:21 AM
    Why is Prisma’s generated-client-code not checked into version control? Whenever a developer working in the codebase runs
    git pull
    , they must then run
    prisma generate
    to update their local environment for any schema changes others may have made. I’m surprised this is the default expectation because it is a hassle. We could create a git-hook to automatically regenerate on every
    pull
    , but it would be simpler to check-in the generated-client-code and add a CI check that ensures the client-code is up-to-date.
    r
    m
    r
    • 4
    • 12
  • t

    Torrino

    10/05/2021, 11:09 AM
    I keep getting
    Already 10 Prisma Clients are actively running.
    showing up in my terminal where I've ran
    prisma studio
    after a few minutes. I'm only instantiating the PrismaClient once when my app launches. This has been the case in the past year but I've only recently started getting this warning so I can't pinpoint the cause. Any help would be gladly appreciated
    r
    • 2
    • 11
  • g

    Gautam Paranjape

    10/08/2021, 5:27 AM
    I have a schema of the following:
    Copy code
    enum MemberRole {
      Owner
      Viewer
      Editor
      Unauthorized
    }
    
    model Member {
      id      String         @id @default(uuid())
      role    MemberRole @default(Unauthorized)
      pending Boolean?       @default(true)
    
      user   User   @relation(fields: [userId], references: [id])
      userId String
    
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
    }
    And using prisma client, I’m trying to create a new
    Member
    like the image attached. For some reason, the role property isn’t showing up even though I tried running generate, and
    db push
    multiple times. Am I doing something wrong?
    r
    • 2
    • 2
  • m

    Marco Schweizer

    10/08/2021, 7:39 AM
    Hi there! I need to check whether two dates overlap. Previously (with TypeORM) I used a raw query like so:
    Copy code
    qb.andWhere(
                '("Appointment"."start_date", "Appointment"."end_date") OVERLAPS (:startDate, :endDate)',
                { startDate: startDate, endDate: endDate }
              );
    Is there any way to make use of OVERLAPS in prisma without having to build the whole query yourself?
    r
    • 2
    • 2
  • n

    Nditah Samweld

    10/10/2021, 5:46 AM
    I encounter this error when I run
    npx prisma migrate dev
    Copy code
    Error: P3014
    
    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>
    
    Original error: 
    db error: ERROR: permission denied to create database
       0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
                 at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:354
       1: migration_core::api::DevDiagnostic
                 at migration-engine/core/src/api.rs:108
    The postgres database connects well
    r
    • 2
    • 1
  • h

    Hugo Marques

    10/10/2021, 2:04 PM
    Is there any way I can generate typescript types to use on frontend code?
    r
    • 2
    • 1
  • m

    Mischa

    10/12/2021, 5:56 AM
    Trying to write a query that fetches users that have unread messages How do I express this in prisma? In particular the LEFT JOIN
    Untitled.sql
  • m

    Mischa

    10/12/2021, 10:34 AM
    https://www.prisma.io/docs/guides/testing/integration-testing#running-the-tests This says
    "migrate:init": "npx prisma migrate dev --name init"
    - why the
    --name init
    bit?
    j
    • 2
    • 14
  • m

    Mischa

    10/12/2021, 2:17 PM
    Having trouble with this queryRaw example from the docs. I had to edit it slightly to get it to type check properly
    Copy code
    interface TableNameQueryResult {
      tablename: string
    }
    export async function truncateAllTables() {
      const qres = await prisma.$queryRaw<
        TableNameQueryResult[]
      >`SELECT tablename FROM pg_tables WHERE schemaname='public'`
      for (const { tablename } of qres) {
        if (tablename !== "_prisma_migrations") {
          // try {
          await prisma.$queryRaw`TRUNCATE TABLE "public"."${tablename}" CASCADE;`
          // } catch (error) {
          // console.log({ error })
          // }
        }
      }
    }
    It gives me this error:
    Copy code
    Invalid `prisma.queryRaw()` invocation:
    
    
          Your raw query had an incorrect number of parameters. Expected: `0`, actual: `1`.
    
          81 |     if (tablename !== "_prisma_migrations") {
          82 |       // try {
        > 83 |       await prisma.$queryRaw`TRUNCATE TABLE "public"."${tablename}" CASCADE;`
             |       ^
    t
    r
    • 3
    • 15
  • r

    Rony Fhebrian

    10/12/2021, 5:54 PM
    hi, I have many-to-many relationship tables with User and Company where users can have many companies and vice-versa. How to create new users where client provides multiple company ids? I’m struggling to figure it out. Should I try in prisma.user.createMany? or prisma.usersCompanies.create()?
    r
    • 2
    • 1
  • m

    Mischa

    10/13/2021, 10:17 AM
    getting an error trying to add an enum type in a postgres migration:
    Copy code
    Error: P3006
    
    Migration `20211013101052_candidate_id_shouldnt_be_unique` failed to apply cleanly to the shadow database.
    Error:
    db error: ERROR: ALTER TYPE ... ADD cannot run inside a transaction block
       0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
                 at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:354
       1: sql_migration_connector::validate_migrations
                 at migration-engine/connectors/sql-migration-connector/src/lib.rs:342
       2: migration_core::api::DevDiagnostic
                 at migration-engine/core/src/api.rs:108
    trying to run
    ALTER TYPE "CandidateSource" ADD VALUE 'OTHER';
    r
    j
    • 3
    • 6
  • m

    Mischa

    10/13/2021, 1:20 PM
    Why I’m eager for prisma generated clients to support ES modules:
  • h

    Hector

    10/13/2021, 3:46 PM
    Hello, is there any way to use the
    include
    API to automatically return all relational fields without specifying them?
    l
    r
    • 3
    • 4
  • m

    Mischa

    10/13/2021, 6:26 PM
    Can you do an “optional”
    include
    ? Like return my objects even if the relation doesn’t exist, like a
    LEFT JOIN
    situation?
    r
    • 2
    • 2
  • k

    koufatzis

    10/14/2021, 7:10 AM
    Hello. Is it possible in Prisma to run
    SELECT FOR UPDATE
    statements ?
    r
    • 2
    • 4
  • a

    Antoine Esteve

    10/14/2021, 3:21 PM
    👋 Hi! I'm wondering if prisma is considering adding a new method to the prisma client to watch changes (change streams). I would love to have type-safe change streams. For mongodb it's easy with https://docs.mongodb.com/manual/changeStreams/ but it may be possible for SQL databases like PostgreSQL using triggers/notify. Any thoughts? It would allow to open prisma to real-time use cases too (graphql subscription, etc).
    r
    a
    • 3
    • 4
  • p

    Paul T

    10/14/2021, 10:27 PM
    Hello. Basic question but can’t seem to find out anywhere in the docs. If I am using the postgres engine, is there a way to view the generated sql from a given prisma query (i.e.
    prisma.model.findMany(...)
    ?
    h
    • 2
    • 3
  • p

    Paul T

    10/14/2021, 10:28 PM
    And also, is there any good articles on how to fine tune query performance?
  • d

    Danny Nemer

    10/15/2021, 12:32 AM
    Why does
    prisma generate
    say it is using a different version of Prisma Client than it has installed? Consequently, it wrongly warns about version mismatch. Thank you!
    r
    • 2
    • 4
  • m

    Mischa

    10/15/2021, 12:16 PM
    docs point to this closed ticket. someone said they need it for postgres but I don't know where to go +1 that. i need bulk pg upserts.
  • t

    Tero Kujala

    10/19/2021, 1:14 PM
    Hi, I have case where I have two entities
    User
    and
    PhoneNumber
    . Phone number can be assigned to only one User. When creating new User I need to assign a phone number, which is coming in request, for created user. The request must fail if phone number is already in use and I also need to take into account possible concurrent requests. My problem is that how I can check that phone number is not already in use? Is the Interactive transactions only way to achieve this?
    r
    • 2
    • 2
1...121314...23Latest