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

    Adimac93

    08/06/2022, 11:27 PM
    Is that a correct behaviour that seeding happens on every connection?
  • a

    Adimac93

    08/06/2022, 11:28 PM
    This is my prisma client init:
    👀 1
    n
    • 2
    • 1
  • l

    Logan

    08/07/2022, 12:08 AM
    Copy code
    model serververification {
      id               String  @id @default(cuid())
      guildId          String  @db.VarChar(20)
      enabled          Boolean @db.Bit(1)
      unverifiedRoleId String? @db.VarChar(20)
      panelMessageId   String? @db.VarChar(20)
      panelChannelId   String? @db.VarChar(20)
      logChannelId     String? @db.VarChar(20)
      verifiedRoleIds  String? @db.LongText
    
      @@index([guildId], map: "guildId_fkey")
    }
    Hey, if my prisma schema looks like this, then my
    prisma.serververfication.create
    shouldn't be asking me to input an
    id
    right? It should create and generate a unique key for the
    id
    field? Because it doesn't seem to be doing that, it tells me its missing a required field.
    Copy code
    serververificationCreateInput.id`: A value is required but not set
    ✅ 1
    👀 1
    r
    • 2
    • 2
  • s

    Slackbot

    08/07/2022, 6:06 AM
    This message was deleted.
    r
    • 2
    • 4
  • k

    konsta

    08/07/2022, 12:33 PM
    Hi TS wizards, can you help me to get rid of the cryptic "IDE" error below? The code works just as intended but I don't understand why TS is not satisfied with it.
    Copy code
    Argument of type '{ where: { priority: { in: ("low" | "medium" | "high" | "urgent")[] | null | undefined; }; status: { in: ("open" | "in progress" | "done" | "in review" | "canceled")[] | null | undefined; }; }; by: ("projectId" | ... 1 more ... | "priority")[]; _count: true; orderBy: { ...; }; }' is not assignable to parameter of type '{ where: { priority: { in: ("low" | "medium" | "high" | "urgent")[] | null | undefined; }; status: { in: ("open" | "in progress" | "done" | "in review" | "canceled")[] | null | undefined; }; }; by: ("projectId" | ... 1 more ... | "priority")[]; _count: true; orderBy: { ...; }; } & { ...; } & (`Error: Field "${string...'.
      Type '{ where: { priority: { in: ("low" | "medium" | "high" | "urgent")[] | null | undefined; }; status: { in: ("open" | "in progress" | "done" | "in review" | "canceled")[] | null | undefined; }; }; by: ("projectId" | ... 1 more ... | "priority")[]; _count: true; orderBy: { ...; }; }' is not assignable to type '{ where: { priority: { in: ("low" | "medium" | "high" | "urgent")[] | null | undefined; }; status: { in: ("open" | "in progress" | "done" | "in review" | "canceled")[] | null | undefined; }; }; by: ("projectId" | ... 1 more ... | "priority")[]; _count: true; orderBy: { ...; }; } & { ...; } & `Error: Field "${number}...'.
        Type '{ where: { priority: { in: ("low" | "medium" | "high" | "urgent")[] | null | undefined; }; status: { in: ("open" | "in progress" | "done" | "in review" | "canceled")[] | null | undefined; }; }; by: ("projectId" | ... 1 more ... | "priority")[]; _count: true; orderBy: { ...; }; }' is not assignable to type '`Error: Field "${number}" in "orderBy" needs to be provided in "by"`'.ts(2345)
    👀 1
    a
    • 2
    • 6
  • o

    Okan Yıldırım

    08/07/2022, 1:30 PM
    Hello friends, I need help about a topic. I want to find if today is my users birthday. I save the data as DateTime and I want to find them without doing a full for loop to check if day and month are same. How can I make a prisma where query to find those users whose day/month of datetime is equal to the params I will give?
    c
    • 2
    • 1
  • n

    Nathaniel Babalola

    08/07/2022, 11:56 PM
    Hi everyone, please what's the best way to store time interval?
    ✅ 1
    c
    n
    • 3
    • 3
  • d

    Dave Edelhart

    08/08/2022, 4:33 AM
    I am getting a wierd error in this orderBy:
    Copy code
    {where: {
        task_type_id: type.id,
        createdAt: {
          gt: new Date(earliestInterval),
        },
      },
      orderBy: {
        createdAt: 'asc',
      },
    };
    src/tasks/repeat/repeat.service.ts7747 - error TS2345: Argument of type ‘{ where: { task_type_id: any; createdAt: { gt: Date; }; }; orderBy: { createdAt: string; }; }’ is not assignable to parameter of type ‘{ select?: taskSelect; include?: taskInclude; where?: taskWhereInput; orderBy?: Enumerable<taskOrderByWithRelationInput>; cursor?: taskWhereUniqueInput; take?: number; skip?: number; distinct?: Enumerable<...>; }’. Types of property ‘orderBy’ are incompatible. Type ‘{ createdAt: string; }’ is not assignable to type ‘Enumerable<taskOrderByWithRelationInput>‘. Type ‘{ createdAt: string; }’ is not assignable to type ‘taskOrderByWithRelationInput’. Types of property ‘createdAt’ are incompatible. Type ‘string’ is not assignable to type ‘SortOrder’. schema is
    Copy code
    model task {
      id           String       @id @default(uuid())
      type         task_type    @relation(fields: [task_type_id], references: [id])
      task_type_id String
      task_events  task_event[]
      notes        String?
      data         Json?
      createdAt    DateTime    @default(now())
      last_work_done  DateTime?
      completedAt  DateTime?
      status       String      @default("started")
      parent_task  task?       @relation(name: "parent", fields: [parent_task_id], references: [id])
      parent_task_id String?
      child_tasks  task[]      @relation(name: "parent")
    }
    I have also tried putting the orderBy in an array
    l
    • 2
    • 1
  • d

    DuckyDev

    08/08/2022, 7:43 AM
    Hi There. I’m about to build a new API and I would like to try Prisma this time. However, the database already exists with 100+ tables in it. Is there a way to auto-generate the classes for the DB entities?
    ✅ 1
    j
    n
    • 3
    • 13
  • q

    Quentin Gilon

    08/08/2022, 3:34 PM
    Hi @channel, We are having trouble finishing the migration from Prism1 to Prisma3. Our prisma3 is using a GraphQL connect to a PostgreSQL on AWS. We did most of the work but are stuck on a few last errors (schema ambiguity). We are looking for help (either freelancer and/or expert Prisma3). Any recommendations? CC @Kevin Justal, our lead developper. Here is the type of errors we are getting.
    ERROR: There is a relation ambiguity during the migration. Please first name the old relation on your schema. The ambiguity is on a relation between CustomerSubscription and Plan. Please name relations or change the schema in steps.
    {
    "data": {
    "deploy": null
    },
    "errors": [
    {
    "locations": [
    {
    "line": 2,
    "column": 9
    }
    ],
    "path": [
    "deploy"
    ],
    "code": 3018,
    "message": "There is a relation ambiguity during the migration. Please first name the old relation on your schema. The ambiguity is on a relation between CustomerSubscription and Plan. Please name relations or change the schema in steps.",
    "requestId": "local:cl6diaxtq001t0818wi9ql9jp"
    }
    ],
    "status": 200
    }
  • f

    Fernando

    08/08/2022, 3:51 PM
    Hello, I'm expecting a query to return results with a
    where
    OR
    condition but I get nothing back, this is what it looks like:
    Copy code
    await prisma.transaction.findMany({
    		where: {
    			OR: [
    				{
    					description: {
    						contains: paramKeyword ? paramKeyword : undefined
    					},
    					value: {
    						equals:
    							paramKeyword && !isNaN(parseInt(paramKeyword)) ? parseInt(paramKeyword) : undefined
    					}
    				}
    			]
    		}
    	});
    Basically I'm trying to implement a really basic search from url params. The column types are
    description: string
    and
    value: number
    . If I comment
    description
    or
    value
    and change nothing else I do get results, but when both conditions are present I get an empty array. Not sure if it matters, but this is on a SQLite db. What am I missing? Thanks!
    ✅ 1
    m
    • 2
    • 4
  • d

    Dhaval Kotak

    08/08/2022, 7:38 PM
    joined #general
    👋 2
  • f

    Francis

    08/08/2022, 11:36 PM
    Hi everyone, is it possible to use unix timestamps or millisecond unix timestamps for createdAt and updatedAt?
    👀 1
    a
    • 2
    • 1
  • s

    sagar lama

    08/09/2022, 5:45 AM
    I'm trying to export data from sql using prisma and download the data over graphql on the frontend, does anyone have any resources I can look into for best practises?
    ✅ 1
    a
    • 2
    • 1
  • a

    Akshay Kadam (A2K)

    08/09/2022, 9:41 AM
    how do i get nested email field from another model & get a flat output bcz
    email
    is 3 levels deep?
    License
    →
    Product
    →
    User
    →
    email
    but i want to query
    prisma.license.findMany()
    & get
    email
    directly.
    Copy code
    export const getLicenses = async (): Promise<
      Array<License & Pick<User, 'email'>> | null | undefined
    > => {
      const userSelect = Prisma.validator<Prisma.ProductSelect>()({
        user: {
          select: {
            email: true,
          },
        },
      })
    
      const productSelect = Prisma.validator<Prisma.LicenseSelect>()({
        product: {
          include: userSelect,
        },
      })
    
      const licenses = await prisma.license.findMany({
        orderBy: {
          createdAt: 'desc',
        },
        include: productSelect,
      })
    
      const result = licenses.map((license) => {
        const email = license.product?.user.email
    
        if (email) {
          return {
            ...license,
            email,
          }
        }
      })
    
      return result
    }
    i get error on the last line
    return result
    saying:
    Copy code
    Type '({ email: string; id: string; name: string; total: number; used: number; productId: string | null; createdAt: Date; product: (Product & { user: { email: string | null; }; }) | null; } | undefined)[]' is not assignable to type '(License & Pick<User, "email">)[]'.
      Type '{ email: string; id: string; name: string; total: number; used: number; productId: string | null; createdAt: Date; product: (Product & { user: { email: string | null; }; }) | null; } | undefined' is not assignable to type 'License & Pick<User, "email">'.
        Type 'undefined' is not assignable to type 'License & Pick<User, "email">'.
          Type 'undefined' is not assignable to type 'License'.ts(2322)
    can't find a way to solve it? here's the full question → https://stackoverflow.com/questions/73289404/get-a-nested-email-field-that-is-part-of-another-model-in-prisma & minimal repro → https://github.com/deadcoder0904/prisma-nested-query-email
    ✅ 1
    m
    • 2
    • 8
  • d

    DuckyDev

    08/09/2022, 10:42 AM
    I have just implemented Prisma in my API (nestjs) which is deployed at azure as an app-service (docker) fails to run for some reason. Anybody who can decipher this error message and point me in the right direction?
    Copy code
    2022-08-09T10:08:52.736172785Z Validation Error Count: 1
    2022-08-09T10:08:52.736175685Z     at LibraryEngine.loadEngine (/node_modules/@prisma/client/runtime/index.js:25244:17)
    2022-08-09T10:08:52.736178785Z     at async LibraryEngine.instantiateLibrary (/node_modules/@prisma/client/runtime/index.js:25185:5)
    2022-08-09T10:08:52.736181685Z     at async LibraryEngine.getConfig (/node_modules/@prisma/client/runtime/index.js:25371:5)
    2022-08-09T10:08:52.736190185Z     at async PrismaService._getActiveProvider (/node_modules/@prisma/client/runtime/index.js:29267:30) {
    2022-08-09T10:08:52.736194185Z   clientVersion: '4.1.1',
    2022-08-09T10:08:52.736197085Z   errorCode: 'P1012'
    2022-08-09T10:08:52.736199985Z }
    👀 1
    m
    a
    • 3
    • 3
  • u

    user

    08/09/2022, 12:00 PM
    Prisma Support for Tracing and Metrics Is Now in Preview 5 min readWe are excited to launch two new features in Preview: Tracing and Metrics. These two features will allow you to monitor and troubleshoot various performance issues effectively. Try them out and share your feedback!
    👍 3
    prisma rainbow 3
    fast parrot 3
  • m

    motiondev

    08/09/2022, 12:35 PM
    Hello everyone, what is the best approach when trying to use the same Prisma client / Prisma artefacts across multiple microservices? Any references or opinions are welcomed! (e.g. I have a two microservices in node and I want to reuse Prisma artefacts so that I don't duplicate code (prisma.schema, migrations, etc) in both codebases)
    ✅ 1
    n
    • 2
    • 3
  • e

    Ennabah

    08/09/2022, 1:14 PM
    Hi everyone We’re having some trouble running migration script in a docker container. Until now, all the tests have been running in a local docker container. We’re getting the following error:
    Copy code
    $ docker exec -it main /bin/sh
    # npx prisma migrate dev --name init
    Environment variables loaded from .env
    Prisma schema loaded from prisma/schema.prisma
    Datasource "db": PostgreSQL database "postgres", schema "public" at "postgres:5432"
    
    Error: P1001
    
    Can't reach database server at `postgres`:`5432`
    
    Please make sure your database server is running at `postgres`:`5432`.
    I have made this project as a guide to reproduce the error I’m receiving, the README.md file contains the steps. I’ve also recorded and attached a (terrible 😬) video recording to show in case you don’t wanna run the project I’m running on MBP M1 Max if that would help, but I hope I’m doing something wrong and it’s not environment related thing
    npd.mov
    ✅ 1
    n
    • 2
    • 4
  • c

    Christophe Rudyj

    08/09/2022, 5:42 PM
    hello I wanted to know do i have to remake the prisma client for ever file that uses it?
    m
    s
    • 3
    • 5
  • r

    robert grimes

    08/09/2022, 8:15 PM
    Is there anything even close to a function that will generate prisma api code from existing database rows?
    ✅ 1
    n
    • 2
    • 1
  • r

    robert grimes

    08/09/2022, 8:16 PM
    as in transform
    insert into foo (balh) values (whatever)
    into
    db.foo.create(...)
    either from sql statements or an existing db
    ✅ 1
    n
    • 2
    • 1
  • s

    Schalk Neethling

    08/09/2022, 8:23 PM
    Prisma can do introspection if that is what you need https://www.prisma.io/docs/concepts/components/introspection
  • s

    Schalk Neethling

    08/09/2022, 8:24 PM

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

  • r

    robert grimes

    08/09/2022, 8:34 PM
    I want the data as well as the schema?
  • r

    robert grimes

    08/09/2022, 8:34 PM
    That just generates a model file right?
  • d

    Dave Edelhart

    08/09/2022, 11:29 PM
    how do you delete a record from a multi-key/unique table? ex:
    Copy code
    model covid_data_pivot {
        iso_alpha_3   String
        field   String
       date       DateTime @db.Date
       increment Int @default(1)
       type    String
       values_int  Int[]
       values_float Int[]
        @@unique([iso_alpha_3, field])
    }
    want to delete a single case of iso_alpha_3 / field incidence so I can write a new record
    ✅ 1
    n
    • 2
    • 3
  • j

    Justin F

    08/10/2022, 4:19 AM
    Is it true that Prisma does not support geojson?
    ✅ 1
    n
    • 2
    • 1
  • d

    Deepak Guptha S

    08/10/2022, 9:45 AM
    👋 Hello, I don't know how to perform bulk insertion, updation or deletion in Prisma for
    GoLang
    Or how to perform transaction for multiple records (insertion, updation or deletion) using
    executeRaw
    👀 1
    ✅ 1
    n
    l
    • 3
    • 2
  • d

    Deepak Guptha S

    08/10/2022, 9:46 AM
    Is there any examples or documentation ?
    ✅ 1
    n
    • 2
    • 1
1...605606607...637Latest