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

    Chris Tsongas

    01/05/2022, 5:09 PM
    Just curious...what are all the "Unchecked" types that get generated by Prisma Client? I keep seeing them but I have no idea what that means....
    n
    • 2
    • 5
  • c

    Caleb

    01/05/2022, 6:56 PM
    Hey all, I have a question regarding migrating data with Prisma AFAIK Prisma cant migrate data and I need help creating a workflow to safely migrate data
  • r

    Richard Kaufman-López

    01/05/2022, 8:18 PM
    What is the best way to handle upserts in a soft-delete middleware? I tried adding
    params.args.where.deletedAt = null
    , but that throws an error because
    Copy code
    Argument where of type PostWhereUniqueInput needs exactly one argument, but you provided id and deletedAt. Please choose one.
    The first idea that comes to mind is to intercept the call, check if the resource exists or not, then replace the action with
    create
    or
    update
    , but honestly, this doesn’t sound right.
  • a

    Aryan Beezadhur

    01/05/2022, 9:36 PM
    Hi! The Prisma docs talk about connection management and managing a connection pool. Is this necessary when using Pgbouncer with PostgreSQL? Another question: Prisma VS Code extension IntelliSense does not work when I use one instance of Prisma as the docs instruct, so when I import a Prisma instance and do
    const foo = await prisma.table...
    I don't get recommendations, only in the file where I created the Prisma instance. How do I get around this, and will it be fixed?
  • t

    Taylor Cantwell

    01/06/2022, 6:18 AM
    is this not allowed in $rawQuery: ``….`
    ${
    cursor
    `?
    WHERE id > ${cursor}
    ORDER BY id ASC
    `LIMIT ${actualLimit}`` `:
    ORDER BY id ASC
    `LIMIT ${actualLimit}``
    }
    ``;`
  • i

    Ivan

    01/06/2022, 10:01 AM
    Hi all! I have a database on supabase, access it using prisma. Everything was working, but suddently it started not working anymore giving me this error Error: `Invalid
    prisma.texture.findMany()
    invocation:` `Can't reach database server at `my credentials`:`5432`` `Please make sure your database server is running at `my credentials`:`5432`.` The databse is not paused. Someone know why this happen?
  • j

    Julien Goux

    01/06/2022, 11:03 AM
    Hello team, any news on the preview interactive transaction feature? : • https://github.com/prisma/prisma/issues/9584 • https://github.com/prisma/prisma/issues/9846 • https://github.com/prisma/prisma/issues/10218 • https://github.com/prisma/prisma/issues/10615 • https://github.com/prisma/prisma/issues/10622
    n
    • 2
    • 6
  • s

    Siemen Blok

    01/06/2022, 1:16 PM
    Hi, can anyone please help me. I'm using Prisma on a Heroku server, I'm trying to deploy the database after I destroyed the last database. Now it's still using the old env variables instead of the new one. Edit: The old env. variable is not in the Heroku settings anymore and the new one is. So when Prisma is logging: 'Environment variables loaded from .env' it in practice is loading them from somewhere else it seems? Edit2: If I retrieve the DATABASE_URL env. with the CLI command:
    heroku config:get DATABASE_URL -s >> .env
    It saves the correct url to my local .env file. So the correct environmental variable is there and is begint used, just not by the Prisma Client. Edit3: So I resolved it by canning the Heroku app and starting from scratch, now I just hope this doesn't happen when my app goes to production 🤞
    l
    • 2
    • 4
  • m

    Max T

    01/06/2022, 2:07 PM
    I've just started using Prisma with Mongo, and I'm already having issues. It seems my queries are taking a really long time. I have GoogleOAuth through Passport, and I run the
    .upsert()
    function to check if a user exists, otherwise I create one. However it appears this query is taking upwards of 30 seconds, meaning the user is stuck on the OAuth consent screen for about that long waiting to be logged in. Any reason or fix for this?
    l
    n
    • 3
    • 6
  • s

    Shmuel

    01/06/2022, 3:46 PM
    This is more of an opinion based general programming question than specific to prisma. Which do you usually do. Do you have the front-end send back a perfectly build up prisma object and just pass it to 
    .create(
     or do you have the back-end build it up? Say for example you want to create a user with posts do you send back- in the body- an object that's prisma specific looking like this...
    Copy code
    {
      data: {
        email: '<mailto:emma@prisma.io|emma@prisma.io>',
        posts: {
          create: [
            {
              title: 'My first post',
              categories: {
                connectOrCreate: [
                  {
                    create: { name: 'Introductions' },
                    where: {
                      name: 'Introductions',
                    },
                  },
                ],
              },
            },
            {
              title: 'How to make cookies',
              categories: {
                connectOrCreate: [
                  {
                    create: { name: 'Social' },
                    where: {
                      name: 'Social',
                    },
                  },
                ],
              },
            },
          ],
        },
      },
    }
    And just dump the prebuilt object into...
    Copy code
    const { id } = await prisma.user.create({
            data: req.body,
          });
    Or do you send back something less prisma specific like this...
    Copy code
    data: {
        email: '<mailto:emma@prisma.io|emma@prisma.io>',
        posts:
          [
            {
              title: 'My first post',
              categories: [
                {
                  name: 'Introductions',
                },
              ],
            },
            {
              title: 'How to make cookies',
              categories:
                [
                  {
                    name: 'Social',
                  },
                ],
            },
          ],
      },
    And then build it up before passing it to the 
    prisma.user.create
     method?
    r
    • 2
    • 5
  • j

    Jason Kleinberg

    01/06/2022, 5:12 PM
    Is https://github.com/prisma/prisma/pull/8842 waiting on something in particular? My project depends on webpack 5, and none of the work-arounds that I am finding are working.
    n
    • 2
    • 1
  • f

    Franco Roura

    01/06/2022, 5:49 PM
    Has anyone here managed to resolve the nexus&prisma null/undefined issue lately?
  • j

    John Smeeth

    01/07/2022, 7:19 AM
    hi all, how can i order by multiple columns?
    n
    • 2
    • 1
  • n

    Necmettin Begiter

    01/07/2022, 8:23 AM
    Hi guys! Great project, very low learning curve! Very nice!
    prisma rainbow 4
    n
    • 2
    • 1
  • j

    Jiří Bartoš

    01/07/2022, 9:42 AM
    Hey all, currently migrating from TypeORM to Prisma and loving it so far! prisma rainbow Is there any way to have multiple different seeders? For example one that is ran always (such as to generate an admin user) and second that would be used only in development (generate random fake data)...
    s
    s
    c
    • 4
    • 9
  • s

    Saim Akhtar

    01/07/2022, 4:03 PM
    Hey everyone, I have started with Prisma a few weeks ago, so far I found it interesting I have a scenario where I want to order by nested relation For example, I have the following relation of one-to-many between item and variants
    Copy code
    model Item {
    id Int
    itemName String @map("item_name")
    variants Variants[]
    }
    
    model Variants {
    id Int
    unitPrice Decimal @map("unit_price")
    item Item
    }
    NOW I want to sort items by minimum price of any of its variant Is there a way I can achieve it via Prisma client, without using raw query to get my mapped fields in schema P.S: Prisma doesn’t provide option of other fields for nested relation apart from _count
    m
    • 2
    • 7
  • c

    Chip Clark

    01/07/2022, 4:46 PM
    db is returning a string, rather than a number, when the value is set to decimal in the schema. . working schema
    Copy code
    model InvoiceTransaction {
      InvoiceTransactionID      Int       @id @default(autoincrement())
      CostCode                  String?   @db.VarChar(40)
      DisbursementAmount        Decimal?  @db.Decimal(20, 2)
      InvoiceNumber             String    @db.VarChar(30)
      InvoiceDate               DateTime? @db.Date 
      InvoiceAmount             Int
    If the InvoiceAmount is changed to Decimal (like the DisbursementAmount) the number is returned as a string.
    Copy code
    InvoiceTransactionID: 23765
    CostCode: null
    DisbursementAmount: "1260"
    InvoiceAmount: 1260
    InvoiceDate: "2020-07-06T00:00:00.000Z"
    InvoiceNumber: "JUN.20 "                       "
    How do I get the API to return the value as a decimal?
  • b

    Bram Adams

    01/07/2022, 6:18 PM
    can someone key me in as to why 2D arrays are not supported? A mutidimensional array is an extremely common use case/data structure
    t
    • 2
    • 4
  • s

    Sebastian Rindom

    01/08/2022, 11:31 AM
    Hey everyone! Have been playing around with migrating github.com/medusajs/medusa from TypeORM to Prisma, but not sure how to approach it given the architecture we have. Will try to explain in a few steps here: • We have a core NPM package that contains core db entities • We have multiple plugins that may or may not include additional db entities • Users of the Medusa install the core package + any plugins that they may want • On bootstrap the core package collects all db entities + all migrations across core and plugins •
    medusa migrations run
    will ensure that all missing migrations from core + plugins are applied Trying to map this to Prisma my thinking so far is this: • Core + Plugins will have
    schema.prisma
    • Core + Plugins will have migrations • *Core will programmatically collect migrations and call Prisma Migrate • *Core programatically creates a Prisma client that is unique to the user’s core + plugins combination My questions are about the last two steps marked with * - 1) are these steps possible and recommended and 2) are there alternative approaches that would be better
  • o

    Omkar Kulkarni

    01/08/2022, 2:00 PM
    Hey there.. need some prisma help
    Copy code
    model Video {
        id String @id @default(uuid())
        reactions Reactions[]
    }
    
    model Reactions {
      id       String       @id @default(uuid())
      type     ReactionType
      user     User?   @relation(fields: [user_id], references: [id])
      user_id String?
    
      video    Video?       @relation(fields: [video_id], references: [id])
      video_id String
    }
    
    enum ReactionType {
      NICE
      YIKES
      KEKW
      POGGERS
    }
    I want to query for a unique video and get count of reactions typewise
    Copy code
    {
         id: "some video uuid",
         title:"My nice video",
         reactions : {
            nice : 44,
            yikes : 2,
            kekw : 41,
            poggers : 3
         }
    }
    any way to query this
  • v

    Ville

    01/08/2022, 3:18 PM
    Let's say I have a model called File. One file can belong to one other model (multiple files can belong to one other model). But there is multiple different models that can own it: Person, Organization etc. How do I model this in Prisma?
  • a

    Astral Gaming

    01/08/2022, 11:14 PM
    Hi, I have a question. Is there a way to add where condition to _count? For example:
    Copy code
    _count: {
        select: {
            posts: true
        },
        where: {
            posts: {
                deletedAt: {
                    equals: null
                }
            }
        }
    }
  • a

    Awey

    01/09/2022, 10:34 AM
    Does anyone have a link to any opensource web applications using Prisma 2?
    n
    • 2
    • 1
  • c

    Chris Bongers

    01/09/2022, 11:41 AM
    I’m trying to migrate a TypeORM project to primsa. I’ve pulled the data, and the schema is created Modified with @@map to reflect the names When I try to run
    npx prisma migrate dev
    I get the following:
    Copy code
    [*] Changed the `photo` table
      [+] Added foreign key on columns (userId)
    
    ? We need to reset the PostgreSQL database "test_db" at "localhost:5432".
    Do you want to continue? All data will be lost.
    How can I go about keeping my data whilst migrating to Prisma from TypeORM? The TypeORM looks like this:
    Copy code
    @Entity()
    export class User {
      @PrimaryGeneratedColumn()
      id: number;
    
      @OneToMany((type) => Photo, (photo) => photo.user)
      photos: Photo[];
    }
    
    @Entity()
    export class Photo {
      @PrimaryGeneratedColumn()
      id: number;
    
      @ManyToOne((type) => User, (user) => user.photos)
      user: User;
    }
    s
    • 2
    • 3
  • m

    Michael Reh

    01/09/2022, 2:42 PM
    Hi , anyone using nx ( monorepo ) and prisma ( 3.7.0 ) ?
    n
    s
    • 3
    • 10
  • s

    Slackbot

    01/09/2022, 3:00 PM
    This message was deleted.
    a
    • 2
    • 1
  • g

    Gaurav Mittal

    01/09/2022, 3:11 PM
    Hi everyone. I hope this is the right place to ask for help. I am trying to run a node program on a fresh Google Cloud instance.
    sudo npm install
    works fine but
    sudo npm start
    gives me this error:
    Copy code
    > npx prisma generate && npx prisma migrate dev && ts-node-dev src/bot.ts
    
    sh: 1: prisma: Permission denied
    Unable to find anything about this on Google search. It ran smoothly on my local with the same commands. node version: 16.6.1 npm version: 7.20.3 Any guidance would be greatly appreciated 🙏
    c
    • 2
    • 2
  • s

    stevebarakat

    01/09/2022, 6:50 PM
    Hello. ✋ Is there a way to
    delete
    an item from the
    db
    and
    update
    all the other items in one
    action
    ? I'm trying to do this:
    Copy code
    js
     await db.task.delete({
            where: {
              id: taskToDeleteId,
            },
          });
          for (let i = 0; i < fixedTasks.length; i++) {
            db.task.update({
              where: {
                id: fixedTasks[i].id,
              },
              data: {
                id: fixedTasks[i].id,
                name: fixedTasks[i].name,
                position: parseInt(fixedTasks[i].position),
                isCompleted: fixedTasks[i].isCompleted,
              },
            });
          }
    I'm getting an error:
    Copy code
    Error: 
    Invalid `db.task.delete()` invocation in
    /Users/sb/Dev/my-remix-dnd/build/index.js:542:27
    
       539   }
       540   break;
       541 case "delete":
    →  542   await db.task.delete(
      Error occurred during query execution:
    ConnectorError(ConnectorError { user_facing_error: None, kind: ConnectionError(Timed out during query execution.) })
        at cb (/Users/sb/Dev/my-remix-dnd/node_modules/@prisma/client/runtime/index.js:38692:17)
        at async action (/Users/sb/Dev/my-remix-dnd/build/index.js:542:7)
        at async Object.callRouteAction (/Users/sb/Dev/my-remix-dnd/node_modules/@remix-run/server-runtime/data.js:36:14)
        at async handleDataRequest (/Users/sb/Dev/my-remix-dnd/node_modules/@remix-run/server-runtime/server.js:110:18)
        at async requestHandler (/Users/sb/Dev/my-remix-dnd/node_modules/@remix-run/server-runtime/server.js:45:20)
        at async /Users/sb/Dev/my-remix-dnd/node_modules/@remix-run/express/server.js:45:22
    Thank you!
  • a

    Aman Tiwari

    01/09/2022, 9:31 PM
    Copy code
    const enquiry = await db.enquiry.findFirst({
        where: { id },
        include: {
          users: {
            include: {
              user: true,
            },
          },
        },
      })
    
      if (!enquiry) throw new NotFoundError()
    
      const partner = enquiry.users.filter((arr) => arr.user.role === "PARTNER")[0]
      const customer = enquiry.users.filter((arr) => arr.user.role === "USER")[0]
    
    return { ...enquiry, partner, customer }
    is this good idea? what are the other way to do?
  • e

    Eudes Tenório

    01/09/2022, 11:00 PM
    Hey guys. How can I have PostgreSQL and MongoDB in the same project using Prisma?
    n
    • 2
    • 1
1...530531532...637Latest