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

    user

    05/10/2022, 8:42 AM
    ๐Ÿ‘‰ What's new in Prisma (v3.14.0) --

    https://www.youtube.com/watch?v=XoS8D8q8icEโ–พ

    -- Niko and Sabin from the Prisma team discuss the latest 3.14.0 release of Prisma and other news from the Prisma ecosystem.
    prisma rainbow 4
  • l

    Lee

    05/10/2022, 11:07 AM
    GraphQLError: Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 30)
    Has anyone seen this error before? Weโ€™re currently being haunted by it, and have tried tweaking connection limits/timeouts/adding pgbouncer/throttling concurrent DB access/nearly everything we can think of and no success ๐Ÿฅฒ
    n
    • 2
    • 3
  • j

    Julian

    05/10/2022, 11:26 AM
    Any way yet to store
    decimal
    in the database without using floats or returning a Decimal.js instance? I just want to store pricing information, but floats can be unprecise and Decimal.js objects are a hassle to work with
    l
    n
    • 3
    • 8
  • l

    Leonard Filip

    05/10/2022, 11:52 AM
    Hi guys! Prisma doesn't pick up when I make changes like so:
    Copy code
    model Author {
    ...
    post Post?
    }
    
    // to
    
    model Author {
    ...
    post Post[]
    }
    I know I should also pluralise the relation field to
    posts
    but is this normal behaviour?
    n
    • 2
    • 6
  • j

    Joe

    05/10/2022, 12:04 PM
    Iโ€™m seeing a common @prisma/client install error:
    Error: Cannot find module '@prisma/client'
    Iโ€™m using the commands:
    npx prisma migrate reset --preview-feature
    npx prisma migrate dev --name init --preview-feature
    npx prisma generate
    n
    • 2
    • 22
  • m

    Mischa

    05/10/2022, 4:25 PM
    wow excited about the postgres improvements! thanks yall!
    ๐Ÿ™Œ 2
    n
    • 2
    • 2
  • j

    Jason Kleinberg

    05/10/2022, 4:40 PM
    Is anyone else having an issue with
    COUNT
    in the improved raw queries? It seems to be throwing with this message:
    Copy code
    Int cannot represent non-integer value: 0
    (Note that the 0 in this case is the count, but I get the same error with other values)
  • j

    Jason Kleinberg

    05/10/2022, 4:53 PM
    Ah, itโ€™s coming back as a
    bidint
    . This is an Apollo issue.
    ๐Ÿ‘ 1
  • a

    aetheryx

    05/10/2022, 4:56 PM
    How can I create a GIN index for a sub-property of a JSON column?
    Copy code
    CREATE INDEX ON table_name((column_name->>'json_prop')) USING GIN (column_name);
    --                                      ^ looking for this behavior
    a
    • 2
    • 2
  • y

    Yaakov

    05/10/2022, 7:05 PM
    How can I order by a variable in a raw query?
    Copy code
    const order = 'last_name ASC, first_name ASC';
    
    await prisma.$queryRaw`SELECT *
                           FROM users
                           ORDER BY ${order}`;
    I'm getting this error `Raw query failed. Code:
    1008
    . Message: `The SELECT item identified by the ORDER BY number 1 contains a variable as part of the expression identifying a column position. Variables are only allowed when ordering by an expression referencing a column name.`` Using SQL Server
    a
    • 2
    • 2
  • m

    Mathie

    05/10/2022, 9:55 PM
    Hello ! How to create relation if not exist ? My code :
    Copy code
    await this.client.modlogsService.createModlogs({
                user: {
                    connect: {
                        userId: user.id
                    }
                },
                type: "WARN",
                date: new Date(),
                moderator: interaction.user.tag,
                reason: reason
            });
    I want to create the user (
    user
    ) if not exist
    s
    • 2
    • 1
  • s

    Sam Weiss

    05/10/2022, 10:52 PM
    I'm trying to model a referral table for my Postgres database. Not sure if the db schema is correct, but I have a table with a
    referId
    , `userId`: 1 to 1, and `referredUserId`: 1 to many. model Referral { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) referId String // Auto Generate Random String userId Int @unique user User @relation(fields: [userId], references: [id]) referredUsersId Int[] referredUsers User[] @relation(fields: [referredUsersId], references: [id]) } I'm not sure exactly how to reference these in the User model. I tried Referral Referral? UsersReferred Referral[] But I get an error
    Error validating model "User": Ambiguous relation detected
    What's the correct way to model a referral table and how can I do it in prisma?
    s
    • 2
    • 16
  • s

    shahrukh ahmed

    05/11/2022, 7:53 AM
    Hi, I have a schema akin to this. I have a need where I need to fetch all posts by
    id
    of the user as well as the
    uuid
    .
    Copy code
    model User {
      id    Int    @id @default(autoincrement())
      uuid  String @default(cuid())
      posts Post[]
    }
    
    model Post {
      id       Int  @id @default(autoincrement())
      author   User @relation(fields: [authorId], references: [id])
      authorId Int
    }
    I get all the posts by authorId by this. How can I do something similar also with UUID?
    Copy code
    const event = await prisma.posts.findMany({
        where: {
          authorId: 1
        }
      });
    b
    n
    • 3
    • 5
  • j

    jeho Ntanda

    05/11/2022, 9:34 AM
    ๐Ÿ‘‹ Hello, team!, nice to be here
  • j

    jeho Ntanda

    05/11/2022, 9:35 AM
    I have however come with an inquiry
  • j

    jeho Ntanda

    05/11/2022, 9:39 AM
    Copy code
    error - Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
    In case this error is unexpected for you, please report it in <https://github.com/prisma/prisma/issues>
    is an error am getting in a nextjs app, but i dont know it
    n
    e
    • 3
    • 6
  • a

    aetheryx

    05/11/2022, 10:33 AM
    Hey guys! Is there any update/ETA on the BigInt issues in Prisma Studio? Our team has been storing BigInts as strings because of the
    queryRaw
    issues and the Prisma Studio bugs - now that
    queryRaw
    is fixed, we're just waiting on these ๐Ÿ˜… https://github.com/prisma/studio/issues/816
    n
    • 2
    • 3
  • m

    Marvin

    05/11/2022, 10:50 AM
    Hey! ๐Ÿ‘‹ How do you normally store analytics data that is not consistent in a database? I'm using postgres and have a model that is also not consistent (it has a
    config
    json for the frontend). I want to track analytics (button clicks, hovers, views) of the elements. Would I store it as simple JSON in the model field called
    analytics
    for example? Can updates collide when incrementing a count for example? I would love to hear your feedback on this because I want to have it in the same database (no separate service beside the postgres database). ๐Ÿ™‚
    n
    • 2
    • 2
  • a

    Alban Kaperi

    05/11/2022, 11:04 AM
    Hi all, I am just trying Prisma but coming from Laravel I am having a bit of difficulty with the seeder. My database is sqlite.
  • a

    Alban Kaperi

    05/11/2022, 11:13 AM
    I have this error for title, description, and price: (property) title: string Type 'string' is not assignable to type 'never'
    Copy code
    const customerData: Prisma.CustomerCreateInput[] = [
        {
            name: 'Alice',
            surname: 'Kaperi',
            email: '<mailto:alice@prisma.io|alice@prisma.io>',
            products: {
                create: [
                    {
                        title: 'Apples',
                        description: 'These are juicy apples',
                        price: 12.5,
                    },
                ],
            },
        },
    ]
    my schema has the following:
    Copy code
    model Customer {
      id    Int     @id @default(autoincrement())
      email String  @unique
      name  String?
      surname  String?
      phone  String?
      code String  @unique
      total_sale Float
      total_quantity Int
      points Int
      address  String
    
      products Product[]  
    
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
    }
    
    model Product {
      id            Int      @id @default(autoincrement())
      title         String
      description   String?
      size          String?
      qty           Int?  @default(0)
      cost          Float
      price         Float
      upc           Int
      reorder_point Int
      manufactuerer String
      last_received DateTime @default(now())
      picture       String
      customer    Customer?    @relation(fields: [customerId], references: [id])
      customerId  Int?
      department    Department?    @relation(fields: [departmentId], references: [id])
      departmentId  Int?
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
    }
    i
    n
    • 3
    • 11
  • u

    user

    05/11/2022, 1:00 PM
    Announcing Prisma Day 2022! Our First Hybrid Prisma Day. Join us June 15th and 16th as we showcase the amazing work thatโ€™s happening throughout the data and application development space. Our first hybrid Prisma Day will take place in Berlin and online!
    ๐Ÿ’ฏ 2
    ๐ŸŽ‰ 2
    ๐Ÿ™Œ 2
    fast parrot 2
    โ›ฑ๏ธ 2
    ๐Ÿ‘€ 1
    prisma rainbow 2
    ๐ŸŒด 2
  • r

    Richard

    05/11/2022, 2:02 PM
    Is it possible to distinguish in the
    rejectOnNotFound
    to which of the provided where conditions makes the query return
    null
    ? (see screenshot with code)
    a
    • 2
    • 4
  • a

    Andrew Leung

    05/11/2022, 7:13 PM
    Hi there, I was wondering if someone could clarify what the correct ENV is to specify the download mirror for the Prisma Engines: https://www.prisma.io/docs/reference/api-reference/environment-variables-reference#prisma_engines_mirror
    a
    j
    • 3
    • 13
  • j

    Junior-Web-Dev

    05/12/2022, 2:29 AM
    I keep getting db error could not determine data type of parameter $1 when i use the same SQL code (without the javascript injection) using my DATAGRIP program, it works. im not sure why im getting this error with prisma
    Copy code
    await prisma.$queryRawUnsafe`UPDATE table SET template_json_data = jsonb_set(template_json_data, '{namingConvention}', '"${String(req.body.projectName)}"', false) WHERE save_id = ${Number(req.body.saveId)}`;
    n
    • 2
    • 2
  • y

    y0on2q

    05/12/2022, 3:57 AM
    hello. I have a question. Why use transaction to one insert or update?? For example,
    Copy code
    await this.prismaService.customer.create({
                data: {
                    name: 'hello',
                    email: '<mailto:ltnscp9028@gmail.com|ltnscp9028@gmail.com>',
                    password: 'password',
                },
            });
    Code create this query.
    j
    n
    • 3
    • 2
  • j

    Julian Tosun

    05/12/2022, 6:46 AM
    How can I turn off these messages?
    j
    n
    • 3
    • 3
  • a

    Aarav Shah

    05/12/2022, 7:45 AM
    Hello @Nurul I implemented the prisma orm with nexus and paljs But we have too many prisma models and due to that nexus take 5 minutes to compile So it is a global issue so I did something wrong on my end
    ๐Ÿ‘€ 1
    a
    n
    n
    • 4
    • 8
  • k

    kyohei

    05/12/2022, 8:45 AM
    Hi I'm trying
    improvedQueryRaw
    and it works localy, but on Vercel it shows
    ERROR	Error: error: The preview feature "improvedQueryRaw" is not known
    . Is there any case possible for 3.14 cannot recognize this flag?
    n
    • 2
    • 2
  • m

    Martin Pinnau

    05/12/2022, 11:35 AM
    Regarding prisma 3.14 and MongoDB: I'm trying to get embedded documents working with mongodb, using prisma 3.14 and the structure according to the schema provided in the release notes of prisma 3.10 ( https://github.com/prisma/prisma/releases/tag/3.10.0 ). Running a query against the db I get an error telling me
    Copy code
    type EmailMessage { .... error: Model declarations have to be indicated with the `model` keyword`
    same error also for EmailSubject my schema:
    Copy code
    model Email {
      id            String @id @map("_id") @db.ObjectId
      name          String @unique
      emailMessage  EmailMessage
      emailSubject  EmailSubject
      receiverGroup Receiver[]
      isActivated   Boolean @default(value: true)
      role          String
      btnName       String
    }
    
    type EmailMessage {
      id        String
      messageDe String
      messageEn String
    }
    
    type EmailSubject {
      id        String
      subjectDe String
      subjectEn String
    }
    
    type Receiver {
      id        String
      email     String
      firstName String
      lastName  String
    }
    What am I doing wrong regarding these embedded documents ? Is there support for embedded document lists but not for embedded documents ?
    n
    • 2
    • 44
  • n

    Niklas

    05/12/2022, 1:25 PM
    Hello all, we use a nodejs prisma backend hosted on Heroku. When we perform certain queries, that involve nested queries on child tables, we lose connection to the database ("Can't reach database server"):
    Copy code
    "Can't reach database server at `<http://ec2-3-68-54-65.eu-central-1.compute.amazonaws.com|ec2-3-68-54-65.eu-central-1.compute.amazonaws.com>`:`5432`
    Please make sure your database server is running at `<http://ec2-3-68-54-65.eu-central-1.compute.amazonaws.com|ec2-3-68-54-65.eu-central-1.compute.amazonaws.com>`:`5432`.
    \",\"stack\":\"Error: Can't reach database server at `<http://ec2-3-68-54-65.eu-central-1.compute.amazonaws.com|ec2-3-68-54-65.eu-central-1.compute.amazonaws.com>`:`5432`
    Please make sure your database server is running at `<http://ec2-3-68-54-65.eu-central-1.compute.amazonaws.com|ec2-3-68-54-65.eu-central-1.compute.amazonaws.com>`:`5432`.
    at Object.request (/app/node_modules/@prisma/client/runtime/index.js:45629:15)
    at async PrismaClient._request (/app/node_modules/@prisma/client/runtime/index.js:46456:18)
    at async getDataFromNestedQuery (/app/src/api/v3/nestedqueryendpoint/controller.js:228:24)\"}}"
    1. When checking the backend-logs we noticed that Prisma runs a nested query instead of a JOIN query (a similar issue is mentioned in https://github.com/seromenho/prisma-join-performance). Can we change the generated queries to a JOIN query? Anybody faced a similar issue? 2. Does setting the
    connection_limit=1
    help? Unfortunately in heroku we are unable to append it to the DATABASE_URL variable. Does anybody have experience with this?
    ๐Ÿ‘€ 2
    n
    • 2
    • 3
1...572573574...637Latest