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

    Melvin Gaye

    07/22/2021, 11:21 PM
    @Edward Baer ty and that's the approach I kind of figured.
  • e

    Edward Baer

    07/22/2021, 11:22 PM
    np, glad I could help someone else for once...
    r
    • 2
    • 6
  • j

    J Giri

    07/23/2021, 3:49 AM
    There is a
    typegraphql-prisma
    issue which i face most often. The feature of "hiding prisma model field in graphql schema" doesnt work most of the time. Presently also its not working As per doc I implemented
    /// @TypeGraphQl.omit(output: true
    to hide the password field in graphql Schema.
    Copy code
    model User {
      id        String @id @default(cuid()) @map("_id")
      firstName String @map("first_name")
      lastName  String @map("last_name")
      email     String @unique
      /// @TypeGraphQl.omit(output: true)
      password  String
    
      @@map("user")
    }
    IN GENERATED TYPES, EXPECTED RESULT SHOULD BE
    Copy code
    @TypeGraphQL.ObjectType({
      isAbstract: true
    })
    export class User {
      @TypeGraphQL.Field(_type => String, {
        nullable: false
      })
      id!: string;
    
      @TypeGraphQL.Field(_type => String, {
        nullable: false
      })
      firstName!: string;
    
      @TypeGraphQL.Field(_type => String, {
        nullable: false
      })
      lastName!: string;
    
      @TypeGraphQL.Field(_type => String, {
        nullable: false
      })
      email!: string;
    
      password?: string;
    }
    BUT WHAT I GET IN GENERATED TYPES IS
    Copy code
    @TypeGraphQL.ObjectType({
      isAbstract: true
    })
    export class User {
      @TypeGraphQL.Field(_type => String, {
        nullable: false
      })
      id!: string;
    
      @TypeGraphQL.Field(_type => String, {
        nullable: false
      })
      firstName!: string;
    
      @TypeGraphQL.Field(_type => String, {
        nullable: false
      })
      lastName!: string;
    
      @TypeGraphQL.Field(_type => String, {
        nullable: false
      })
      email!: string;
    
      /** @TypeGraphQl.omit(output: true) */
      @TypeGraphQL.Field(_type => String, {
        nullable: false,
        description: "@TypeGraphQl.omit(output: true)"
      })
      password!: string;
    }
    What I get in my unexpected result is not hiding graphql schema field. What am i getting unexpected result? In the past very few times i got expected generated types. Most often if emits the unexpected output, which is mentioned above, in generated types
    r
    • 2
    • 17
  • r

    Roy Segall

    07/23/2021, 7:23 AM
    Hi, I have a group by and I'm trying to load the relationship as well. In the
    findMany
    we can do
    include
    but how can I do it in
    groupBy
    ?
    r
    • 2
    • 3
  • h

    Halvor

    07/23/2021, 11:13 AM
    How can i use my prisma Enum definitions in typescript?
    l
    r
    • 3
    • 6
  • u

    user

    07/23/2021, 11:42 AM
    Set up a local PostgreSQL Database on macOS

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

    In this video we look at how easy it is to get a PostgreSQL server running locally on macOS. We step through installing the Postgres App, initializing a user database and connecting to it using the
    psql
    command. Download the Postgres Mac App: https://postgresapp.com/ Setting up a local PostgreSQL Database guide: https://www.prisma.io/dataguide/postgresql/setting-up-a-local-postgresql-database Prisma's Data Guides for PostgreSQL: https://www.prisma.io/dataguide/postgresql Make interfacing with your data super simple with Prisma's PostgreSQL connector: https://www.prisma.io/docs/concepts/database-connectors/postgresql 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
  • h

    Halvor

    07/23/2021, 1:47 PM
    How can i select rows that contain a relation to another table?
  • h

    Halvor

    07/23/2021, 1:47 PM
    Copy code
    prisma.stat.count({
            where: {
                arbitrated: {
                    where: {
                        session_id: arbitratedSessionId
                    }
                }
            }
  • h

    Halvor

    07/23/2021, 1:48 PM
    I the "session_id" is unique in the table arbitrated. And arbitrated has one-to-many relation with the stat table.
  • h

    Halvor

    07/23/2021, 1:49 PM
    I want to check if rows referencing that particular arbitrated row with given session_id exists in stat table.
    r
    • 2
    • 5
  • m

    Melvin Gaye

    07/23/2021, 2:26 PM
    Quick question. Can prisma handle migrations of procs? And how would I do that?
    r
    • 2
    • 2
  • n

    Naotho Machida

    07/23/2021, 3:30 PM
    r
    • 2
    • 4
  • j

    Jan Georg

    07/23/2021, 6:59 PM
    Hello, I struggle with seeding my db: I have a self referencing entity and if i seed multiple childs to the same parent, only the last child will have a parentId. Everything else works, all the children are in the database... just the parentIds are missing... does anyone have a clue for me? 🙂
    Copy code
    model Item {
      id          String  @id 
      name        String
      parentId    String?
      parent      Item?   @relation("ItemHierarchy", fields: [parentId], references: [id])
      predecessor Item?   @relation("ItemHierarchy")
    }
    
    // seed.js
    await prisma.item.upsert({ id: "1", name: "1" }
    await prisma.item.upsert({ id: "2", name: "2", { parent: { connect: { id: "1" } } } }
    await prisma.item.upsert({ id: "3", name: "3", { parent: { connect: { id: "1" } } } }
    ...
    await prisma.item.upsert({ id: "10", name: "10", { parent: { connect: { id: "1" } } } }
    r
    • 2
    • 1
  • h

    Harun

    07/24/2021, 9:20 AM
    Hi guys, i am making custom CRM-CMS with nodejs, where it will be versioned, and the customer will be able to update their own app, just like wordpress. The app will be hosted with and without docker. Does anyone know how i can get the app updated with one simple click from nodejs api? 1. If it's deployed with docker, it should update the docker image. 2. If it's not deployed with docker, it should directly update the nodejs application.
  • i

    Ivan

    07/24/2021, 9:27 AM
    Hi all! I've an issue. I've put new fields in one of my schema model, but they doesn't show up in production. Everything is working in development mode (when i visit my website in the localhost), but in production (when i visit my url website) the new fields doen't show up. I'm hosting my Postgresql database on Supabase, i've also tried to make another database from scratch, but just these new fields just doesn't show up in production mode. I've tried everything, from npx migrate dev/deploy to db push, and as i said, even to create a new database from scratch! But nothing worked. I think this is a really strange issue, am i missing something?
    d
    • 2
    • 5
  • l

    Luis Cardoso

    07/24/2021, 4:40 PM
    I have two tables: Users and Tasks. Users has a one-to-many relation with the Tasks table (meaning an user can have many tasks). I’m trying to create a task with a signed in user but I’m getting an
    Copy code
    Unique constraint failed on the fields: (`id`)
    this is my service:
    Copy code
    async createTask(
        createTaskDto: Prisma.TaskCreateInput,
        user: User,
      ): Promise<Task> {
        return this.prismaService.task.create({
          data: {
            ...createTaskDto,
            user: {
              create: user,
            },
          },
        });
      }
    and here is my db schema:
    Copy code
    model Task {
      id          String     @id @default(uuid())
      title       String     @db.VarChar(20)
      description String     @db.VarChar(200)
      status      TaskStatus @default(OPEN)
      user        User      @relation(fields: [userId], references: [id])
      userId      String
    }
    
    model User {
      id    String  @id @default(uuid())
      email String  @unique
      name  String?
      password String
      tasks Task[]
    }
    I’m don’t know what is wrong, maybe I’m not getting how the relations work in Prisma. Can someone help me?
    ✅ 1
    • 1
    • 1
  • a

    arun

    07/24/2021, 4:45 PM
    Build a Modern Data App Hackathon - by DataStax! ⭐️ We are excited to have you as part of the hackathon! To ensure that you have access to all the resources and information you need, we have included important information below: https://bit.ly/2WhL7Qz
  • m

    Michał K

    07/24/2021, 7:16 PM
    Hi 👋 I would like to push a PR to the
    prisma-examples
    repo but getting the perm error. Is there a way to do that (I feel like i am missing sth 🙈 )
    r
    a
    • 3
    • 8
  • h

    Halvor

    07/25/2021, 1:02 PM
    How can i case insensitive check against a username?
    Copy code
    where: { 
        username: username
    }
    m
    r
    • 3
    • 5
  • s

    Shubham Patil

    07/26/2021, 12:27 AM
    where can i get prisma logos? I wanted to add prisma to my portfolio site
  • h

    Halvor

    07/26/2021, 1:13 AM
    Is it possible to have string as unique value while make it case insensitive? I mean that there can only be one username with the same characters, no matter what case?
    r
    • 2
    • 3
  • h

    Halvor

    07/26/2021, 1:13 AM
    I use findUnique() and username is a string with the @unique flag.
  • a

    alisalimli

    07/26/2021, 2:49 AM
    Hi guys,can i host prisma in digital ocean(dokku).If i can,how ? There isn't any tutorial
    r
    • 2
    • 50
  • n

    Naotho Machida

    07/26/2021, 3:21 AM
    Hi guys... how I can get a random data in prisma?
    r
    • 2
    • 1
  • s

    Sofiane Akermoun

    07/26/2021, 3:25 AM
    Hi, little question i would like to perform something like: SELECT * FROM users WHERE id % 2 != 0; Is it possible to filtering like this with Prisma ?
    r
    • 2
    • 2
  • j

    Jemin Kothari

    07/26/2021, 10:13 AM
    Hello @Ryan @Ahmed I added
    previewFeatures = ["orderByRelation"]
    to support sorting with the relation model. And it is working fine with prisma client. But in my project I used nexus and pal js with prisma and created graphql endpoint. So how can I implement
    orderByRelation
    with nexus graphql. Is there any docs?
    a
    • 2
    • 23
  • a

    Angelo

    07/26/2021, 10:31 AM
    Good morning, I have ran some seeds against the database at the same time that someone else was doing some queries against it, Postgres started complaining about it:
    cached plan must not change result type
    After some googling I came up with a stackoverflow answer with people that managed to avoid that problem by doing this in the java driver
    You can avoid the problem by configuring your 
    pgjdbc
     driver with 
    autosave=conservative
    .
    So I was trying to see if Prisma had an option like that anywhere but couldn’t find any reference to it, does someone know what the problem is or if there is such a setting that I can set in Prisma?
    r
    • 2
    • 1
  • h

    Halvor

    07/26/2021, 11:40 AM
    I need to check if a row exists in a table, is this the best way to do that?
    Copy code
    prisma.arbitrated.count({
            where: {
                id: 100
            }
        }) > 0;
    r
    • 2
    • 10
  • k

    khareta

    07/26/2021, 12:52 PM
    facing a weird error, where it complains that
    is
    isn't there, so I add it, then it starts complaining that
    is
    is an unknown arg, did you mean id? so I remove is. What's going on here? calling prisma.model.count()
    r
    • 2
    • 2
  • h

    Henri Kuper

    07/26/2021, 1:07 PM
    I am using prisma studio. Studio queries in the background findMany lets say on a model users. The query includes everything. Also all n:m relations. This leads to a huge amount of data. Lets imagine a relation contains > 1k connections. The simple findMany query would fetch all these 1k relations as well. If I manually unselect all n:m relations in prisma studio, they are not shown in prisma studio, but as I see it, they are still queried. For a model like users, that may have an attribute followers this query fetches so many data, that you run into a timeout.. Do I miss anything or is it not possible to remove specific attributes from include in these automated queries?
    r
    • 2
    • 4
1...462463464...637Latest