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

    Cornelius

    07/14/2021, 1:57 PM
    Hello ;) I am just trying to find out how to access the triple comments "///" I put into my schema definition. Where are they located when I make console.log(prisma)?
    r
    • 2
    • 4
  • c

    Cornelius

    07/14/2021, 1:57 PM
    Thanks for your help in advance 😘
  • b

    Benjamin Kroeger

    07/16/2021, 11:19 AM
    The TypeScript type for ModelWhereUniqueInput when model only has a single unique field still marks that single field as optional. Is it somehow possible to make that one field required? Maybe a generator flag?
    Copy code
    export type ModelWhereUniqueInput = {
      id?: string
    }
    r
    • 2
    • 4
  • r

    Ridhwaan Shakeel

    07/17/2021, 10:21 PM
    does prisma client throw an exception or status code if you are trying to delete a table row that is not found, if so what is it?
    r
    • 2
    • 2
  • j

    James

    07/18/2021, 3:14 PM
    Hi, what's the reason for this https://github.com/prisma/prisma/blob/c8a179be2547ce9bcc6b1f60285d6fba98ffa03a/src/packages/engine-core/src/BinaryEngine.ts#L274 - I plan to launch ~100 prisma instances on 1 server.. Any thoughts?
    r
    • 2
    • 4
  • b

    Ben Ezard

    07/19/2021, 12:37 PM
    When running tests (via Jest) that use Prisma, I get a warning about open handles Jest provides this info about it:
    Copy code
    Jest has detected the following 1 open handle potentially keeping Jest from exiting:
    
      ●  prisma-client-request
    
          35564 |       try {
          35565 |         let index = -1;
        > 35566 |         const resource = new import_async_hooks.AsyncResource("prisma-client-request");
                |                          ^
          35567 |         const params = {
          35568 |           args: internalParams.args,
          35569 |           dataPath: internalParams.dataPath,
    I'm calling
    prismaClient.$disconnect()
    when tests are done; is there something else that I should be doing to avoid this? I wasn't sure if this is a bug or not, but if it is then I'll raise an issue on GitHub about it 🙂
    r
    • 2
    • 4
  • h

    hayes

    07/20/2021, 7:09 PM
    Got a kinda weird question. Given a model name, and the name of a field that is a relation to another model, is there a way to extract the name of the model associated with that relation (at runtime)?
  • h

    hayes

    07/20/2021, 7:32 PM
    Looks like dmmf has what I am looking for.
  • b

    Brian Woodward

    07/22/2021, 8:21 PM
    Hi 👋 ... I just started using
    prisma
    and it's been great. At first, I didn't realized there's an additional executable that runs to make the client work. I replaced using
    pg
    with
    @prisma/client
    and noticed that my deployment to kubernetes kept crashing. This was due to having a low requested memory limit. A couple of questions: • Is there a minimum or recommended memory requirement to run the
    prisma
    engine (postgres in this case)? • What's the best way to monitor and possibly handle memory usage of the engine from within my Node.js process?
    r
    • 2
    • 2
  • s

    sven

    07/23/2021, 9:47 AM
    Is there a way to create a strict typeGuard function other than writing it by hand?
    p
    • 2
    • 2
  • p

    Phong Ho

    07/29/2021, 9:14 AM
    Does anybody know how to override decimaljs’s prototype for prisma’s decimal value?
    Decimal.prototype.toJSON
    r
    • 2
    • 2
  • p

    Phong Ho

    07/29/2021, 9:16 AM
  • p

    Phong Ho

    07/29/2021, 9:17 AM
    result[0].protection
    ’s type is decimal in prisma model.
  • n

    Niko Guerra

    07/30/2021, 7:57 PM
    Has anyone ever had an issue with a .create() not executing, but not giving an errors or warnings or query logs either? Have
    log: ['info', 'error', 'warn', 'query']
    turned on, but get nothing for one of my queries, and I've console logged my way to check that the function is properly async and is properly receiving data, it's just like the code skips over that block for some reason?
    • 1
    • 1
  • s

    Sting Alleman

    07/31/2021, 10:12 PM
    Hi all. I have a function that wraps around a findUnique function, and that function passes a include query to the findUnique.
    Copy code
    async getUser(
        userId: string,
        conf?: { include?: Prisma.UserInclude; select?: Prisma.UserSelect }
      ): Promise<User> {
        return await this.prisma.user.findUnique({
          where: { id: userId },
          ...conf
        });
      }
    Now, If I do, for example, getUser("id", {include: { posts: true }) , the return type of getUser will be wrong, because it doesn't include the posts relation. I can fix this using generics, but that would mean that I also always have to add the
    User
    generic. Is there another, better way to fix these return types?
    👀 1
  • o

    Omkar Kulkarni

    08/01/2021, 8:49 AM
    Hey.. I want to get search results along with count of them.. is this the correct way to it ?
    const usersWithCount = await prisma.$transaction([
                
    prisma.user.count({
                   
    where: { username: { startsWith: keyword.toLowerCase() } },
                
    }),
                
    prisma.user.findMany({
                   
    where: {
                      
    username: {
                         
    startsWith: keyword.toLowerCase(),
                      
    },
                   
    },
                
    }),
             
    ])
             
    return {
                
    users: usersWithCount[1],
                
    total: usersWithCount[0],
             
    }
    r
    • 2
    • 2
  • j

    Jay Bell

    08/02/2021, 5:32 PM
    Hey everyone, for some reason. CI when I have postgres running and run
    prisma db push
    I get
    Copy code
    {
      "timestamp": "2021-08-02T17:27:04.778303482+00:00",
      "level": "ERROR",
      "fields": {
        "is_panic": false,
        "error_code": "P1003",
        "message": "Database `<db name>.public` does not exist on the database server at `localhost:5432`."
      },
      "target": "migration_engine::logger"
    }
    Shouldn't it create the db if it doesn't already exist? It does on another step in CI (and locally) which is weird... the step that does not work is using docker executor and the one that does work is using ubuntu machine executor (both on circleci) Anyone have any ideas here? I am at a loss.
    r
    • 2
    • 23
  • k

    koufatzis

    08/03/2021, 11:28 AM
    Hey what is the best way to dockerize a node.js app using Typescript and Prisma without installing dev dependencies in the final image ? Do you have any tutorials for that ?
    r
    d
    • 3
    • 6
  • k

    koufatzis

    08/03/2021, 11:51 AM
    Btw there seems to also be an open issue for an example Dockerfile https://github.com/prisma/prisma-examples/issues/1856
    r
    • 2
    • 17
  • s

    Slackbot

    08/03/2021, 12:23 PM
    This message was deleted.
    r
    • 2
    • 1
  • t

    timothé david

    08/03/2021, 7:49 PM
    hello I have a big problem sinc few days ( don't understand ... )
  • t

    timothé david

    08/03/2021, 7:49 PM
    i use nest with prisma
  • t

    timothé david

    08/03/2021, 7:49 PM
    it worked few week ago
  • t

    timothé david

    08/03/2021, 7:49 PM
    there are my file :
  • t

    timothé david

    08/03/2021, 7:50 PM
    Copy code
    // This is your Prisma schema file,
    // learn more about it in the docs: <https://pris.ly/d/prisma-schema>
    
    datasource db {
      provider = "postgresql"
      url      = env("DATABASE_URL")
    }
    
    generator client {
      provider = "prisma-client-js"
    }
    
    model user {
      id            Int    @id @default(autoincrement())
      access_token  String @unique
      refresh_token String @unique
      expiry_date   Int
      email         String @unique
    }
  • t

    timothé david

    08/03/2021, 7:50 PM
    prisma file i could push to the db
  • t

    timothé david

    08/03/2021, 7:50 PM
    Copy code
    import {
      INestApplication,
      Injectable,
      OnModuleInit,
      OnModuleDestroy,
    } from '@nestjs/common';
    import { PrismaClient } from '@prisma/client';
    
    @Injectable()
    export class PrismaService extends PrismaClient implements OnModuleInit {
      async onModuleInit() {
        await this.$connect();
      }
    
      async enableShutdownHooks(app: INestApplication) {
        this.$on('beforeExit', async () => {
          await app.close();
        });
      }
    }
  • t

    timothé david

    08/03/2021, 7:50 PM
    prisma service
  • t

    timothé david

    08/03/2021, 7:51 PM
    it tell me everytime it cannot read the user cause of undefined
    h
    • 2
    • 3
  • t

    timothé david

    08/03/2021, 7:52 PM
    if someone coulld help ...
1...91011...23Latest