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

    Dan

    10/21/2021, 12:22 AM
    Why does
    updateMany
    not allow
    skip
    and
    take
    ?
  • d

    Dan

    10/21/2021, 12:27 AM
    https://github.com/prisma/prisma/issues/9878
  • e

    Ethan Zoller

    10/21/2021, 4:18 AM
    I have my API and DB hosted on DigitalOcean. When I call an API function that uses Prisma it returns in the logs Invalid ``prisma.bot.findMany()` invocation: connect ECONNREFUSED :1281` . I have my DB open to all connections, not sure why this is occurring. It wasn't happening earlier with the same configuration. Do I need to update or something?
    j
    • 2
    • 6
  • e

    Ethan Zoller

    10/21/2021, 4:19 AM
    It's also working on development just fine
  • l

    Lars Ivar Igesund

    10/21/2021, 8:10 AM
    Just a quick question (for when we eventually move to Prisma 2/3/++) - if a prisma node is in a managed, serverless environment (like GCP Cloud Run), and we want to protect access using mechanisms there, then it (currently at least) requires that the prisma client in the application node is able to set additional authorization headers. In prisma1 it is not possible to do this, and an additional issue is that Google IAM also prefers the Authorization: Bearer token way, so there is a conflict if one wants to both secure the perimeter and the application-to-prisma authorization. So I think prisma should have the ability to 1) set/add headers to the request to be processed by proxies or whatever in front of the prisma node 2) ability to customize which headers prisma uses, e.g. it could add --x-prisma-authorization: Bearer token as an alternative (at least until some RFC comes along to handle this situation (if it didn't already))
    r
    • 2
    • 2
  • y

    Yaakov

    10/21/2021, 11:53 AM
    How may I define a 3-way relationship as many-to-many? Suppose I have the following schema: vendors
    Copy code
    - id
    - name
    services
    Copy code
    - id
    - name
    areas
    Copy code
    - id
    - name
    vendors_services_areas
    Copy code
    - vendor_id
    - service_id
    - area_id
    
     @@id([vendor_id, service_id, area_id])
    How can this be defined in Prisma Schema and how do I add a new vendor mapped to its two relationships?
    r
    • 2
    • 8
  • u

    user

    10/21/2021, 12:51 PM
    Building a Fullstack app using NextJS and Prisma - CityJS Conf 2021

    https://www.youtube.com/watch?v=aim8Mk-ETK0▾

    In this workshop you will learn how to build a fullstack app using Next.js & Prisma. This workshop was recorded at CityJS Conf 2021: https://cityjsconf.org/ Lear more at: https://twitter.com/cityjsconf Code: https://github.com/m-abdelwahab/nextjs-prisma-workshop 00:00 - workshop intro 00:41 - a look at the starter branch 04:36 - getting started with Prisma 06:58 - installing Prisma and using
    prisma init
    07:34 - writing the Prisma schema 11:29 - set up a PostgreSQL database using cloud.prisma.io/postgres.app 16:44 - creating a migration 19:21 - seeding the database 26:00 - question: are Prisma and GraphQL related? + live debugging + recap 29:20 - initializing Prisma Client in a Next.js app 31:21 - creating API endpoint for submitting feedback 36:08 - sending requests to the
    create endpoint
    from the frontend 42:00 - displaying the list of feedback 45:49 - Next.js getServerSideProps serializing problem 47:25 - Recap, Conclusion, and questions
  • n

    Nic Luciano

    10/21/2021, 12:59 PM
    hi all. thank you for this channel. my company loves Prisma. i am having trouble using custom client output in a monorepo with NPM 7 workspaces, which hoists all packages to a root
    node_modules
    . i am having 2 strange issues. any help with either one would be amazing, i suspect they are related. i apologize for the wall of text, it's mostly debug output!!! a quick tour of the monorepo:
    Copy code
    rpphub/node_modules/@prisma
    rpphub/package.json
    
    db workspace source (the prisma project):
    rpphub/workspaces/db/package.json
    rpphub/workspaces/db/schema.prisma
    rpphub/workspaces/db/migrations/*
    rpphub/workspaces/db/lib (client output goes here)
    rpphub/workspaces/db/lib/index.js
    rpphub/workspaces/db/lib/schema.prisma
    rpphub/workspaces/db/lib/[...the rest of the generated files..]
    
    and finally a nextjs app trying to utilize prisma client:
    rpphub/workspaces/web
    furthermore, my
    rpphub/workspaces/db/package.json
    contains inclusion directives:
    Copy code
    "main": "lib/index.js",
    "browser": "lib/index-browser.js",
    "types": "lib/index.d.ts"
    ***issue 1***: the client does not work from the node REPL for certain working directories. if i am in the
    rpphub/workspaces/db
    directory i can have the following session:
    Copy code
    $:~/Code/rpphub/workspaces/db$ node
    Welcome to Node.js v14.15.4.
    Type ".help" for more information.
    > const plib = require('.')
    undefined
    > const client = new plib.PrismaClient()
    undefined
    but if i am in the
    rpphub
    directory, a similar session fails:
    Copy code
    $:~/Code/rpphub$ node
    Welcome to Node.js v14.15.4.
    Type ".help" for more information.
    > const plib = require('./workspaces/db')
    undefined
    > const client = new plib.PrismaClient()
    Uncaught:
    Error: ENOENT: no such file or directory, open '/home/nic/Code/rpphub/.git/schema.prisma'
        at Object.openSync (fs.js:476:3)
        at Object.readFileSync (fs.js:377:35)
        at new LibraryEngine (/home/nic/Code/rpphub/workspaces/db/lib/runtime/index.js:36078:40)
        at PrismaClient.getEngine (/home/nic/Code/rpphub/workspaces/db/lib/runtime/index.js:39108:16)
        at new PrismaClient (/home/nic/Code/rpphub/workspaces/db/lib/runtime/index.js:39079:29) {
      errno: -2,
      syscall: 'open',
      code: 'ENOENT',
      path: '/home/nic/Code/rpphub/.git/schema.prisma',
      clientVersion: '3.3.0'
    }
    ***issue 2***: the code fails runtime when being included in my Nextjs project in
    rpphub/workspaces/web
    . at runtime,
    import * as PrismaClient from "@rpphub/db";
    results in
    Copy code
    error - Error: Cannot find module 'os'
        at webpackEmptyContext (/home/nic/Code/rpphub/workspaces/web/.next/server/pages/api/test.js:53:10)
        at ../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js (webpack-internal:///../db/lib/runtime/index.js:1738:15)
        at __require2 (webpack-internal:///../db/lib/runtime/index.js:87:45)
        at ../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js (webpack-internal:///../db/lib/runtime/index.js:2002:56)
        at __require2 (webpack-internal:///../db/lib/runtime/index.js:87:45)
        at eval (webpack-internal:///../db/lib/runtime/index.js:30776:33)
        at Object.../db/lib/runtime/index.js (/home/nic/Code/rpphub/workspaces/web/.next/server/pages/api/test.js:42:1)
        at __webpack_require__ (/home/nic/Code/rpphub/workspaces/web/.next/server/webpack-runtime.js:33:42)
        at eval (webpack-internal:///../db/lib/index.js:17:5)
        at Object.../db/lib/index.js (/home/nic/Code/rpphub/workspaces/web/.next/server/pages/api/test.js:32:1) {
      code: 'MODULE_NOT_FOUND'
    which you can see stems from
    var os2 = __require("os");
    in
    rpphub/workspaces/db/lib/runtime/index.js.
    . i recognize this could definitely be more of a next-question than a prisma question, if that's the case i apologize! i thought next might require further module transpilation but i had no luck going that route. thank you all!
    j
    • 2
    • 2
  • d

    David Sooter

    10/21/2021, 3:59 PM
    Hi there, Does Prisma have support for views in Postgres?
    a
    • 2
    • 1
  • l

    Leo Li

    10/21/2021, 4:29 PM
    Hey I read this Advanced type safety (Reference) but I want to know how to ensure type safety with the JSON field in a model in case I know its type, is there a generic to cast JSON field in my model?
    a
    • 2
    • 2
  • n

    Noel Martin Llevares

    10/21/2021, 5:22 PM
    How do you rollback? Use case: During deployment, we execute the migrations, then deploy the app. If the app deployment fails, we should be able to rollback immediately because a migrate database may break the app.
    a
    d
    • 3
    • 3
  • b

    Bruno Casado

    10/21/2021, 5:58 PM
    Prisma Version: 2.30.3 Guys i'm trying to explain my problem so i edited the message: The following works as intended:
    Copy code
    TableA {
      fieldA_id int
      fieldA  Gene    @relation(fields: [fieldA_id], references: [id])
    }
    Gene {
      ...
      TableA TableA[]
    }
    But after i changed the Gene TableA to use 2 fields but same opposition relationship it stops to works: like:
    Copy code
    fieldA_id int
    fieldB_id int
    fieldA  Gene    @relation(name: "field_a_pk", fields: [fieldA_id], references: [id])
    fieldB  Gene    @relation(name: "field_b_pk", fields: [fieldB_id], references: [id])
    error: WomanCareInfo = TableA in this case.
    Copy code
    error: Error validating field `gene_loc_1` in model `WomanCareInfo`: The relation field `gene_loc_1` on Model `WomanCareInfo` is missing an opposite relation field on the model `Gene`. Either run `prisma format` or add it manually.
      -->  schema.prisma:335
       | 
    334 | 
    335 |   gene_loc_1 Gene @relation(name: "gene_1_pk", fields: [gene_1_id], references: [id])
    336 |   gene_loc_2 Gene @relation(name: "gene_2_pk", fields: [gene_2_id], references: [id])
       | 
    error: Error validating field `gene_loc_2` in model `WomanCareInfo`: The relation field `gene_loc_2` on Model `WomanCareInfo` is missing an opposite relation field on the model `Gene`. Either run `prisma format` or add it manually.
      -->  schema.prisma:336
       | 
    335 |   gene_loc_1 Gene @relation(name: "gene_1_pk", fields: [gene_1_id], references: [id])
    336 |   gene_loc_2 Gene @relation(name: "gene_2_pk", fields: [gene_2_id], references: [id])
    337 |
    is this a sort of bug?
    • 1
    • 1
  • m

    Michael Aubry

    10/21/2021, 6:24 PM
    Hoping someone might have some insights here https://prisma.slack.com/archives/CA491RJH0/p1634766321288700
  • t

    Tom MacWright

    10/21/2021, 7:42 PM
    Is this the right place to ask about bugs and crashes?
    👍 2
    r
    • 2
    • 1
  • g

    Gabe O'Leary

    10/21/2021, 7:44 PM
    I tried to perform a prisma migrate on a table with ~30k records which took ~30 minutes after which I cancelled it and now when I retry it I get this message:
    Copy code
    The migration `...` failed.
    ? We need to reset the PostgreSQL database "..." at "...".      
    Do you want to continue? All data will be lost. » (y/N)
    also if I try to query the table on which the migration was attempted it runs for minutes without returning anything... Seems like I've corrupted my DB. Luckily I don't care that much about this data, but I would like to know what likely went wrong so I can avoid it in the future. This table does have a JSON column with a potentially sizeable amount of data....is that what might've resulted in the migration command taking so long? Also I had datagrip connected to the db when I triggered the migrate...is this an issue?
    a
    • 2
    • 7
  • t

    Tom MacWright

    10/21/2021, 8:20 PM
    selecting a count of relations, like in this API example, is there a way to filter the counted rows? say, if you have a
    deleted
    column in posts and only want to count the non-deleted posts? https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#include-a-_count-of-relations
    a
    • 2
    • 5
  • t

    Tom MacWright

    10/21/2021, 8:26 PM
    afaict, it isn't possible
  • n

    Noel Martin Llevares

    10/21/2021, 11:58 PM
    Hi, I am new to Prisma and evaluating it for my projects. I have a few questions and I appreciate if anyone can answer. I’ll post them in separate threads for easier reading.
  • n

    Noel Martin Llevares

    10/21/2021, 11:58 PM
    How do you do a data migration where the migration only contains DML statements instead of the usual DDL?
    r
    • 2
    • 1
  • n

    Noel Martin Llevares

    10/21/2021, 11:59 PM
    Does Prisma support native SQL functions for queries?
    r
    • 2
    • 1
  • n

    Noel Martin Llevares

    10/21/2021, 11:59 PM
    Is there a way to declare the connection parameters dynamically on a per-request basis? Use case: On a multi-tenant B2B app where there is only one app instance but separate databases per tenant, each request may connect to a different customer database.
    r
    • 2
    • 1
  • n

    Noel Martin Llevares

    10/22/2021, 12:00 AM
    How does prisma know the dependency between migrations? Is it just based on the timestamps of the generated migration files?
    r
    • 2
    • 1
  • n

    Noel Martin Llevares

    10/22/2021, 12:06 AM
    How does Prisma handle schema drift due to unsupported features such as data types, views and triggers?
    r
    • 2
    • 1
  • a

    Ahmed Khan

    10/22/2021, 5:41 AM
    Hello, How can I rewrite this query cleanly using
    prisma.purchaseBill
    api and not using a raw query. I read somewhere that we can't compare two column values in prisma as of now ?
    r
    • 2
    • 6
  • h

    henry

    10/22/2021, 5:50 AM
    Hi Everyone, please how can i setup Prisma(mysql) to allow users add new roles dynamically and assign privilege /permission to the roles?
    r
    • 2
    • 4
  • u

    user

    10/22/2021, 7:03 AM
    Prisma Interviews with Robert Craigie & Luca Steeb - Prisma Client for Python

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

    In this video, Daniel from the Prisma team interviews Robert Craigie who created the Python Client for Prisma which brings the benefits of type safety to the Python community. They are also joined by Luca Steeb, a Software Engineer at Prisma who's working on the Prisma Client for Golang. They discuss Robert's motivation for creating the Python Client, type safety in Python, and the technical details of building a Prisma Client for languages other than TypeScript. 🐍 Learn more about the Prisma Python Client: https://prisma-client-py.readthedocs.io/en/latest/ 🦫 Prisma Go Client: https://github.com/prisma/prisma-client-go • Robert Craigie - Software Developer and Student at Dundee University in Scotland. Robert had been programming with Python for 5 years and the Prisma Python Client is the first open-source project he's released. Connect with Robert at: https://twitter.com/probablyrobert • Luca Steeb - Software Engineer at Prisma primarily working on the Go Client, currently available in Early Access. Connect with Luca at: https://twitter.com/steebchen *Timestamps 00:00 - Intro 00:14 - Prisma Python Client origins 00:20 - From raw SQL to Prisma 00:33 - Typesafety in Python 05:16 - The Prisma Go Client 06:41 - Rust Prisma engine vs Clients 09:51 - Ways of building Prisma Clients 10:24 - DMMF explanation - Domain Model Meta Format 12:46 - How DMMF can be used in Python 15:17 - Nested writes in the Python Client 20:31 - Python Client community & feedback 21:25 - How the Prisma CLI is used 23:18 - Is it possible to use Rust bindings to directly make calls to the Rust binary similarly to how the Prisma Node API works 25:09 - What's next for the Prisma Python Client
  • a

    Albin Groen

    10/22/2021, 7:09 AM
    Does anybody know what the status is on precompiled Prisma binaries for ARM processors?
    r
    • 2
    • 2
  • j

    Jemin Kothari

    10/22/2021, 7:29 AM
    Hello @Ryan I created model called
    List
    and
    Activity
    Copy code
    model List {
     id   Int             @id @default(autoincrement())
     Activity             Activity[]
     @@map("list")
    }
    
    model Activity {
     id             Int          @id @default(autoincrement())
     status         String
     list_id        Int
     List           List        @relation(fields: [list_id], references: [ID])
     @@map("activity")
    }
    a
    • 2
    • 10
  • b

    Bård

    10/22/2021, 9:14 AM
    Hey, Considering this schema:
    Copy code
    model Questionnaire {
      id             Int             @id @default(autoincrement())
      title          String
      description    String
      maxLength      Int?
      validationType String
      media          Json
      sequence       Int          @unique
      userQuestions  UserQuestions[]
    }
    
    model UserQuestions {
      id            Int           @id @default(autoincrement())
      answer        String?
    
      uid          String
      questionnaireId Int?
      
      user          User          @relation(fields: [uid], references: [id])
      questionnaire Questionnaire? @relation(fields: [questionnaireId], references: [id])
    }
    I'm trying to createMany UserQuestions entries. But when I try to connect them to the Questionnaire it doesn't recognize "questionnaire" on the UserQuestions model. Code:
    Copy code
    prisma.userQuestions.createMany({
      data: [
        {
          uid,
          questionnaire: {
            connect: {
              sequence: 1,
            },
          },
        },
        {
          uid,
          questionnaire: {
            connect: {
              sequence: 2,
            },
          },
        },
        {
          uid,
          questionnaire: {
            connect: {
              sequence: 3,
            },
          },
        },
      ],
    });
    Error:
    Copy code
    Unknown arg `questionnaire` in data.0.questionnaire for type UserQuestionsCreateManyInput. Did you mean `questionnaireId`? Available args:
    type UserQuestionsCreateManyInput {
      id?: Int
      answer?: String | Null
      uid: String
      questionnaireId?: Int | Null
    }
    r
    • 2
    • 2
  • b

    Bojan Šernek

    10/22/2021, 9:49 AM
    I’m considering pulling some projects together in a Nx monorepo to share code and typings; has anyone done a Nx monorepo that contains multiple prisma clients? Or maybe some other kind of typescript monorepo solution that works with Prisma?
1...497498499...637Latest