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

    Akash Anand

    01/23/2022, 9:53 AM
    Hi, Can anyone help here, when I trying "prisma1 deploy". it is giving me this error
  • a

    Adrian

    01/23/2022, 10:26 AM
    I have one doubt about Prisma architecture. What's the reasoning behind using an engine build in Rust?
  • a

    Adrian

    01/23/2022, 10:27 AM
    I think Prisma and NextJS are the only ones I have seen using Rust somehow with the JS ecosystem
  • l

    Lars Ivar Igesund

    01/23/2022, 10:32 AM
    Seems quite obvious that you would consider using a performant, safe language to build a backend service that will need to be able to scale?
  • l

    Lars Ivar Igesund

    01/23/2022, 10:32 AM
    FWIW, Prisma 1 is written in Scala and runs on the JVM
  • a

    Adrian

    01/23/2022, 10:39 AM
    How would it scale?
  • l

    Lars Ivar Igesund

    01/23/2022, 10:43 AM
    By using clusters, cloud, serverless, whatever, like anything you would want to scale
  • m

    Manish

    01/23/2022, 11:48 AM
    Hi In the following query:
    Copy code
    const users = await prisma.user.findMany({
      include: {
        posts: true
      },
    })
    Is it possible to limit the number of posts that are returned. For example, can I limit it to 10 posts for that user to be included in the relation?
    n
    m
    • 3
    • 5
  • r

    Rich Starkie

    01/23/2022, 5:14 PM
    is it possible to pass a variable in to the
    prisma.<table>.<action>
    so I can reuse a funtion for multiple tables?
    j
    • 2
    • 45
  • s

    Salvage

    01/23/2022, 7:08 PM
    https://github.com/prisma/prisma/issues/11341 just made an issue about theoretical rust support, would love some feedback on the issue
  • l

    Lars Ivar Igesund

    01/23/2022, 7:33 PM
    This is not what you are asking, but you know that prisma as it is, is written in Rust?
  • s

    Salvage

    01/23/2022, 7:50 PM
    I know yeah, which is weird why there isn't a client / crate for Rust.
  • r

    Raj Chaudhary

    01/24/2022, 5:46 AM
    My prisma schema is as follows:
    Copy code
    model User {
      id BigInt @id
      createdAt DateTime @db.Timestamptz(3) @default(now())
      updatedAt DateTime @db.Timestamptz(3) @updatedAt
      accountId BigInt
      account Account @relation(fields: [accountId], references: [id])
      fullName String
      email String
      oauthToken String?
    }
    The generated sql file is as follows:
    Copy code
    CREATE TABLE "User" (
        "id" BIGINT NOT NULL,
        "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
        "updatedAt" TIMESTAMPTZ(3) NOT NULL,
        "accountId" BIGINT NOT NULL,
        "fullName" TEXT NOT NULL,
        "email" TEXT NOT NULL,
        "oauthToken" TEXT,
    
        CONSTRAINT "User_pkey" PRIMARY KEY ("id")
    );
    However prisma client does not mark the User.oauthToken as nullable in TS. Can anyone help?
  • t

    Thibaut De Maerteleire

    01/24/2022, 7:58 AM
    Is it possible to change nullable values to undefined in the generated types?
  • h

    Hubert Kowalski

    01/24/2022, 8:35 AM
    Hi, are there any plans for supporting openssl 3.0?
  • n

    Nathaniel Bajo

    01/24/2022, 10:10 AM
    Who understand how prisma works here?
  • n

    Nathaniel Bajo

    01/24/2022, 10:11 AM
    So I created a server with rust and the server runs on my raspberry pi 4, the server has some commands it executes which is why I used prisma as it's database to store they values
  • n

    Nathaniel Bajo

    01/24/2022, 10:12 AM
    But raspberry pi4 does not work with prisma engines
  • n

    Nathaniel Bajo

    01/24/2022, 10:12 AM
    And the program I'm running requires it which is why I want to build prisma engines and migrate it manually with a script
  • n

    Nathaniel Bajo

    01/24/2022, 10:13 AM
    But I don't know how to do that and I tried creating a script for it but it did not work
  • n

    Nathaniel Bajo

    01/24/2022, 10:13 AM
  • n

    Nathaniel Bajo

    01/24/2022, 10:14 AM
    So does anyone know what I'm doing wrong ?
  • n

    Nathaniel Bajo

    01/24/2022, 10:15 AM
    By the way I
    git cloned
    the prisma engine repo and `cargo build --release`ed it on my raspberry pi
  • n

    Nathaniel Babalola

    01/24/2022, 10:38 AM
    Good day all, please How can I delete all the data in my database with one command using Prisma?
    m
    • 2
    • 6
  • e

    Elijah Rosier

    01/24/2022, 10:50 AM
    Hey, does anyone know why my count (seen below) is supposedly returning
    number
    when in reality it returns
    { _count: { _all: 14 } }
    ?
    Copy code
    prisma.sentimentResponse.count({
            where: {
              contentId: pathParameters.contentId,
            },
          })
    Is there something I'm doing wrong? I'm not casting it anywhere
    • 1
    • 1
  • n

    Nathaniel Babalola

    01/24/2022, 11:29 AM
    Good day, Please at what point in my docker file should I create models with Prisma. I haven't used prisma with docker before
  • a

    AlexSPx

    01/24/2022, 11:31 AM
    Copy code
    model Course {
      name        String  @id @unique
      public_name String?
      details     Json?
      published   Boolean @default(false)
    
      model ModelType @default(WEEKLY)
      weeks Int?
    
      // Relation Fields
      members    CourseEnrollment[]
      dataModels CourseDataModel[]
      @@map("course")
    }
    
    model CourseDataModel {
      id    String   @id @default(uuid())
      name  String
      type  DataType
      props Json
    
      // Relation Fields
      document_id   String?     @unique
      document      Document?   @relation(fields: [document_id], references: [id], onDelete: Cascade)
      video_id      String?     @unique
      video         Video?      @relation(fields: [video_id], references: [id], onDelete: Cascade)
      course_id     String
      course        Course      @relation(fields: [course_id], references: [name], onDelete: Cascade)
      assignment_id String?     @unique
      assignment    Assignment? @relation(fields: [assignment_id], references: [id], onDelete: Cascade)
      quiz_id String? @unique
      quiz Quiz? @relation(fields: [quiz_id], references: [id], onDelete: Cascade)
    
      @@map("courseDataModel")
    }
    ^^^ This is my prisma schema Is there a way to write a query that selects all the courses and count each dataModel where the value of "document_id" is not undefined
  • a

    AlexSPx

    01/24/2022, 11:31 AM
    Copy code
    const courses = await prismaClient.course.findMany({
          where: {
            published: true
          },
          select: {
            name: true,
            public_name: true,
            details: true,
            weeks: true,
          },
          include: {
            _count: {
              select: {
                dataModels: {
                  where: {...}
                }
              }
            }
          }
        })
    Something like this
  • s

    Stijn

    01/24/2022, 12:59 PM
    Hi everyone, I've got a question if something I came across is a bug or if I did something wrong, I got this error when I'm trying to use `set`:
    Copy code
    Invalid `prisma.project.update()` invocation:
    
    
      The change you are trying to make would violate the required relation 'ProjectToUserProject' between the `Project` and `UserProject` models.
    details:
    {
      code: 'P2014',
      clientVersion: '3.8.1',
      meta: {
        relation_name: 'ProjectToUserProject',
        model_a_name: 'Project',
        model_b_name: 'UserProject'
      }
    }
    This is my schema.prisma:
    Copy code
    model UserProject {
      projectId Int
      project   Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
      userId    Int
      user      User    @relation(fields: [userId], references: [id], onDelete: Cascade)
    
      @@id([userId, projectId])
    }
    
    model Project {
      id         Int       @id @default(autoincrement())
      name       String
      users  UserProject[]
    }
    This is the code:
    Copy code
    const project = await db.project.update({
      where: { id },
      data: {
        ...data,
        users: {
          set: users?.map(user => ({
            userId_projectId: {
              userId: user.userId,
              projectId: id,
            },
          }))
        }
      },
    })
    r
    • 2
    • 3
  • s

    Shmuel

    01/24/2022, 8:54 PM
    Hi, I'm running tests using jest and would like to return the database to its original state after each test. I'm trying to use a transaction like the following, but it's not working (using SQLServer).
    Copy code
    beforeEach(async () =>  {
      await prisma.$queryRaw`BEGIN TRAN`;
    });
    
    afterEach(async () => {
      await prisma.$queryRaw`ROLLBACK TRAN`;
    });
    I'm getting the following error.
    Copy code
    Raw query failed. Code: `266`. Message: `Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0.`
    How can I accomplish this?
1...536537538...637Latest