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

    Nurul

    08/25/2022, 6:52 AM
    Hi 👋 For Prisma Python-related queries, Prisma Python GitHub Discussions should be an ideal place. Robert Craigie should be able to help you out.
    ✅ 1
  • b

    Ben Patton

    08/25/2022, 2:58 PM
    Is the prismaClient for Go still available? Been using Go recently and love prisma, just wanted to get up and running with db's quick and use Go as my server
    ✅ 1
    r
    • 2
    • 6
  • m

    Michael Roberts

    08/25/2022, 3:31 PM
    Hi there, can anyone tell me why I am seeing these ts errors please:
  • m

    Michael Roberts

    08/25/2022, 3:32 PM
    Unsafe assignment of an
    any
    value.
  • m

    Michael Roberts

    08/25/2022, 7:18 PM
    Can anyone give me any guidance on why this is occuring? What have I done wrong please?
    a
    • 2
    • 2
  • m

    Mischa

    08/25/2022, 8:29 PM
    is there some sort of generic TS type that represents a table delegate? like prisma.myTable prisma.otherTable - what type do these both share?
    👀 1
    a
    • 2
    • 1
  • j

    John Rinehart

    08/25/2022, 8:42 PM
    I'm using
    prisma
    with
    nesjs
    and I have a very small part of my application where I temporarily need to change the connection (different credentials).
    👋 1
  • j

    John Rinehart

    08/25/2022, 8:42 PM
    The only examples of
    prisma
    with
    nestjs
    that I see involve configuring the DB at start-up. Makes sense for most use cases, but how can I accomplish an ephemeral connection?
    👀 1
    ✅ 1
    a
    • 2
    • 2
  • j

    John Rinehart

    08/25/2022, 8:43 PM
    Write load will be really low, so no worries about connection handshaking throttling the DB.
  • a

    Austin

    08/25/2022, 9:02 PM
    Hey Philipp, The name of the field in the
    schema.prisma
    dictates what field name will be used in the Prisma Client queries. You could rename the field to
    users
    in your schema, but with an explicit m2m relation, it’s often helpful to know at a glance what fields relate to the join table directly so it’s common practice to use names like
    usersOnActivities
    .
    v
    • 2
    • 1
  • a

    Adam Żbikowski

    08/25/2022, 11:02 PM
    Hey everyone, I'm trying really hard to deploy a CMS called keystone which makes heavy use of Prisma. My whole setup is running in Docker containers, and the backend, during build time, calls
    prisma migrate deploy
    . I have a Postgres db running in a separate container with a generated connection string that is passed via env vars. For some reason I keep getting this error during build:
    Error: P1001: Can't reach database server at <postgres_container_name>:5432
    I have verified I can connect to the database container by pinging it from a different app container (my frontend), but the CMS along with Prisma won't connect to it. If it helps, my server runs on arm64 architecture, and I have tried both Node v16 (LTS) and v14 images for the build. I also tried adding a connection timeout to my connection string. Nothing helps! Any pointers highly appreciated.
    👀 1
    n
    • 2
    • 5
  • j

    Jacob Coker-Dukowitz

    08/25/2022, 11:41 PM
    Anyone using Interactive Transactions in production? If so, for how long?
    ✅ 1
    n
    • 2
    • 1
  • b

    Ben Guthrie

    08/26/2022, 5:23 AM
    Hello 👋 We've recently seen a few
    Can't reach database server at ...
    from Prisma. These errors show up usually when we're running a lot of queries at once. Most of the queries will work and then one random query will throw this error. Previously, we've seen helpful errors about connection limits/timeouts and tuned out parameters accordingly. But now it seems like something is shutting down the entire connection to the database.The Postgres db we're using is hosted on AWS RDS. Has anyone seen anything like this? Any tips for how we can debug what is causing Prisma to not be able to reach the db?
    ✅ 1
    n
    • 2
    • 13
  • n

    Nurul

    08/26/2022, 9:38 AM
    Hey 👋 It seems to work for me on Safari, does the issue persist even if you refresh and try again?
    e
    • 2
    • 7
  • y

    Yerzhan

    08/26/2022, 10:14 AM
    👋 Hi all! I need a help with
    DATABASE_URL
    for
    CloudSQL
    when project deployed with
    GCP Cloud Run
    . I’m using
    postgresql
    . already tried these approaches: 1.
    DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@${CLOUD_SQL_Public_IP_address}/${DB_DATABASE}?socket=/cloudsql/${CLOUD_SQL_INSTANCE_CONNECTION_NAME}&connection_limit=50&pool_timeout=30
    2.
    DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@localhost/${DB_DATABASE}?schema=public&host=/cloudsql/${CLOUD_SQL_INSTANCE_CONNECTION_NAME}
    But still having this issue:
    Copy code
    Can't reach database server at `xxx.xxx.xx.x`:`5432`
    Please make sure your database server is running at `xxx.xxx.xx.x`:`5432`.
    Prisma clientVersion: ‘3.13.0’ Thank you!!!
    ✅ 1
    a
    • 2
    • 3
  • m

    Matheus Assis

    08/26/2022, 3:20 PM
    Why is
    findUnique
    more recommended than just fetching with
    findMany
    What’s the difference between
    db.users.findUnique({ where: { id } }).posts()
    and
    db.posts({where: { userId: id }})
    Edit: Oh I found this: https://www.prisma.io/docs/guides/performance-and-optimization/query-optimization-performance#solving-n1-in-graphql-wit[…]que-and-prismas-dataloader
    ✅ 1
    n
    • 2
    • 1
  • m

    Mischa

    08/26/2022, 3:39 PM
    any info on using the new tracing feature with AWS Xray? anything special that needs to be configured? it looks like there should be some way to bridge prisma otel with xray via https://aws-otel.github.io/docs/getting-started/lambda/lambda-js
    a
    • 2
    • 2
  • p

    Phorcys

    08/26/2022, 8:03 PM
    hey, I'm looking at the unit testing guide but I don't understand it. all the guide tells you is to mock the PrismaClient and it just works ?? I don't understand
    ✅ 1
    a
    • 2
    • 24
  • p

    Phorcys

    08/26/2022, 8:07 PM
    something else, how do I get my ``@id`` to be ``userId`` by default?
    Copy code
    model Teacher {
      id String @id @default(cuid())
    
      user   User   @relation(fields: [userId], references: [id], onDelete: Cascade)
      userId String @unique
    }
    👀 1
    b
    n
    • 3
    • 6
  • m

    Millerbyte

    08/26/2022, 10:38 PM
    Hello! So I found this thread on creating a readable stream to query data through Prisma — is there a way to use a writable stream to import records in a way that’s transaction-safe? For example, I have a
    read stream
    that reads raw csv data -> pipes that into a
    write stream
    that parses the data using
    csv-parse
    -> pipes that into a
    transform stream
    that converts it into a javascript object / entity. I would like to add a final
    write stream
    at the end of this pipeline that inserts each entity, one at a time (or in a batch), all in one transaction.
    👀 1
    n
    • 2
    • 4
  • d

    David Ilizarov

    08/26/2022, 11:22 PM
    Every now and then I pop into this Slack and read the announcements for updates... one day I'll read that Json types in the Schema for PostgreSQL can be typed :')
    ✅ 1
    n
    • 2
    • 1
  • d

    David Ilizarov

    08/26/2022, 11:22 PM
    🙏
  • d

    Dave Edelhart

    08/27/2022, 3:44 AM
    the all-or-nothing createMany is suboptimal - a “binary re-submit” would be ideal in situations where “hit or miss” is acceptable an option to re-submit split chunks until all the acceptable records are in would be good.
    👀 1
    ✅ 1
    n
    • 2
    • 1
  • c

    Cryptic

    08/27/2022, 9:04 AM
    Hey interested if there will possibly be support for planetscale serverless drivers
    n
    g
    • 3
    • 5
  • k

    Kay Khan

    08/27/2022, 6:09 PM
    Some of us are having trouble with using prisma in a serverless environment and getting it working both locally and in production - https://github.com/prisma/prisma/issues/14258 any official help is appreciated
    r
    k
    • 3
    • 4
  • i

    ikbenignace

    08/28/2022, 4:03 PM
    Hello, I do have a recursive database and I actually want to see all the childs of every parent
    Copy code
    where: {
            masterId: null,
          },
          include: {
            translations: true,
            childs: {
              include: {
                translations: true,
                childs: {
                  include: {
                    translations: true,
                    childs: true,
                  },
                }
              },
            }
          },
  • i

    ikbenignace

    08/28/2022, 4:04 PM
    But how can i just get all levels instead of a maximum defined level like in my json above
    👀 1
    n
    • 2
    • 1
  • m

    Motdde

    08/29/2022, 2:43 AM
    Is it a good practise to make API calls in a Prisma Transaction?
    ✅ 1
    n
    • 2
    • 3
  • m

    Mananshi Jaymin Vyas

    08/29/2022, 5:20 AM
    Hello, team! I am trying to implement a multi-tenant architecture in my Express Application and I wanted to write a middleware to connect to a database and inject it into Prisma client dynamically. Can someone guide me as to how can that be done? So far the resources I've obtained are an npm package prisma-multi-tenant and few blogs 1. https://medium.zenika.com/building-a-multi-tenant-application-with-prisma-11bf890304d6 2. https://darioielardi.dev/schema-based-multi-tenancy-with-nestjs-and-prisma (I'd like to use Node instead of Nestjs)
    ✅ 1
    n
    • 2
    • 2
  • g

    Gustavo

    08/29/2022, 5:22 AM
    Hi team, for some reason whenever I need to alter a table in my already created database, I'm getting
    Table xxxxxx is marked as crashed and should be repaired
    👀 DB Engine:
    Mariadb
    , although when I configured the
    datasource
    is set to
    mysql
    Copy code
    datasource db {
        provider = "mysql"
    Copy code
    expressjs@24d28168baba:/application$ npx prisma --version
    Environment variables loaded from .env
    prisma                  : 4.2.1
    @prisma/client          : 4.2.1
    Current platform        : linux-arm64-openssl-1.1.x
    Query Engine (Node-API) : libquery-engine 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules/@prisma/engines/libquery_engine-linux-arm64-openssl-1.1.x.so.node)
    Migration Engine        : migration-engine-cli 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules/@prisma/engines/migration-engine-linux-arm64-openssl-1.1.x)
    Introspection Engine    : introspection-core 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules/@prisma/engines/introspection-engine-linux-arm64-openssl-1.1.x)
    Format Binary           : prisma-fmt 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules/@prisma/engines/prisma-fmt-linux-arm64-openssl-1.1.x)
    Default Engines Hash    : 2920a97877e12e055c1333079b8d19cee7f33826
    Studio                  : 0.469.0
    this is the migration file that makes prisma throw the error:
    Copy code
    /*
      Warnings:
    
      - You are about to drop the column `documentTypeId` on the `organisationDocuments` table. All the data in the column will be lost.
      - You are about to drop the column `organisationId` on the `organisationDocuments` table. All the data in the column will be lost.
      - Added the required column `projectId` to the `organisationDocuments` table without a default value. This is not possible if the table is not empty.
    
    */
    -- AlterTable
    ALTER TABLE `organisationDocuments` DROP COLUMN `documentTypeId`,
        DROP COLUMN `organisationId`,
        ADD COLUMN `projectId` INTEGER NOT NULL;
    
    -- AddForeignKey
    ALTER TABLE `organisationDocuments` ADD CONSTRAINT `organisationDocuments_projectId_fkey` FOREIGN KEY (`projectId`) REFERENCES `projects`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
    but I believe the table crashed on a previous migration which is:
    Copy code
    -- AlterTable
    ALTER TABLE `organisationDocuments` MODIFY `content` LONGTEXT NOT NULL;
    so I'm unsure why it was marked as crashed... This has happened to me several times on different tables whenever I need to alter a table in development, command i'm using is:
    Copy code
    inside_container> npx prisma migrate dev --name "...." --schema="path/to/schema.prisma" --skip-seed
    Any ideas? 🤔
    👀 1
    a
    • 2
    • 2
1...613614615...637Latest