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

    Paul

    05/29/2021, 4:46 PM
    No I'm getting ahead of myself. I'm still waiting for it: https://github.com/prisma/prisma/issues/5560
  • j

    Jack

    05/29/2021, 9:05 PM
    My question in #prisma2 got archived, so I'll ask it here now. Is there a way to have optional lists? I saw a while back that it was under discussion. It seems silly that it wouldn't be possible. My use case is: company is a model, that may or may not be hosting an event. Event is another model. A company can have many events or none.
    r
    • 2
    • 1
  • t

    Tom

    05/30/2021, 6:17 AM
    Hi, use prisma studio for my production database on render following this guide: https://github.com/blitz-js/blitz/wiki/How-to-Run-Prisma-Studio-in-Production-on-Render.com. It used to work fine but now, after a few weeks not using it, I'm getting this error in prisma studio:
    Copy code
    Error in HTTP Request (Status: 401) {}
    It's probably something with authentication. If I enter the wrong password I don't see this error popup but the login window clears. So the reason for this error are not invalid credentials. In the logs I can see this:
    Copy code
    {
      "level": "error",
      "ts": 1622364163.8549633,
      "logger": "http.log.access",
      "msg": "handled request",
      "request": {
        "method": "POST",
        "uri": "/api",
        "proto": "HTTP/1.1",
        "remote_addr": "10.123.123.123:54321",
        "host": "<http://prisma.mydomain.com|prisma.mydomain.com>",
        "headers": {
          "Content-Length": [
            "220"
          ],
          "Accept-Encoding": [
            "gzip, deflate, br"
          ],
          "Te": [
            "trailers"
          ],
          "X-Forwarded-For": [
            "123.123.123.123"
          ],
          "Origin": [
            "<https://prisma.mydomain.com>"
          ],
          "X-Forwarded-Proto": [
            "https"
          ],
          "User-Agent": [
            "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0"
          ],
          "Accept": [
            "*/*"
          ],
          "Accept-Language": [
            "en-US,en;q=0.5"
          ],
          "Content-Type": [
            "application/json"
          ],
          "Dnt": [
            "1"
          ],
          "X-Request-Start": [
            "1622366163855563"
          ]
        }
      },
      "common_log": "10.201.104.156 - - [30/May/2021:06:12:43 +0000] \"POST /api HTTP/1.1\" 401 0",
      "duration": 0.00003197,
      "size": 0,
      "status": 401,
      "resp_headers": {
        "Server": [
          "Caddy"
        ],
        "Www-Authenticate": [
          "Basic realm=\"restricted\""
        ]
      }
    }
    I re-deployed the whole app and tried different browsers and users but always get the same error. I'm not quite sure if this is a prisma issue but maybe you have an idea how to debug it. Thanks!
    ✅ 1
    j
    • 2
    • 10
  • j

    Jin

    05/30/2021, 11:03 AM
    [ Looking for a prisma graphQL Server Developer 🔥] Currently, I am preparing startup for mobile app. I am looking for someone whom I can enjoy working together on several projects. and would like to share profit as a business partner. ( Not  salary base ) There are preffered condition. • Experience of Docker,  Prisma gql server and server management. • Living in Germany or similar time zone • Responsible person with passion
    Please feel free to send Direct Message  🦜
  • g

    Gustav Walter

    05/30/2021, 11:55 AM
    Hello I can't seem to find an answer on my question so I'll give it a shot here: I'm trying to fetch some data from a product table using:
    Copy code
    const response = await prisma.product.findUnique({
              where: {
                name: name,
              },
            });
    and it's complaining about the name type when I try to build, please look at the attached image. Now it's complaining about the type, the name was originally a string but I changed it to any, but I still can't seem to get it to work. My model for the product table is:
    Copy code
    model Product {
      id         Int         @id @default(autoincrement())
      name       String      @unique
      price      Int
      orderItems OrderItem[]
    }
    and the error message is: Type error: Type '{ name: any; }' is not assignable to type 'ProductWhereUniqueInput'. I'm assuming it has something to do with the @unique part in the table and the type around it. If anyone know how to solve this, feel free to contact me! 🙂 Thanks //Gustav
    т
    l
    r
    • 4
    • 5
  • b

    Beyond

    05/30/2021, 3:41 PM
    Please, how do I delete cascaded tables in Prisma? I have having user table in relation with user_priviledges and I want a situation where if I delete a user, it should as well delete the user privileges but I'm getting error
    r
    • 2
    • 3
  • j

    James

    05/30/2021, 11:53 PM
    Hi team, so after I use the prisma to migrate, it will remove the data from the database, so what is the best way to retain the data from postgres after migration is done? Do I need to export the data out of the database first (pg-dump dbname > outfile), do the prisma migrate, then import the data back to the database (psql dbname < infile)?
    k
    b
    e
    • 4
    • 14
  • c

    Chris Baucom

    05/31/2021, 3:49 AM
    Hi Prisma Family prisma - I’ve been running into issues getting a Next.js + Prisma + Graphql + TypeScript project to a stable point. I don’t think the issue I am now running into is Prisma related but figured I would ask in hopes someone might be able to help. I’ve created a CodeSandbox where you can see everything I have setup so far and the error in the screenshot. Any help is much appreciated 🙏
    r
    • 2
    • 7
  • j

    Julien Goux

    05/31/2021, 7:10 AM
    Hello team, would it be possible to have an ETA about this? https://github.com/prisma/prisma/issues/6882#issuecomment-848859778
    j
    • 2
    • 2
  • j

    Julien Goux

    05/31/2021, 7:10 AM
    This is pretty critical for anyone wanting to play with postgres row level security as it’s session dependent
    j
    r
    • 3
    • 4
  • i

    Ibad Shaikh

    05/31/2021, 7:23 AM
    Hi prisma family👋 I have a question related to
    $transaction
    query. My current code (which is not working yet) :
    const _users_ = _await prisma.user.findMany_({
          
    _select_:_ _{ _id_: _true_, _username_: _true_ },
    _    _})
    _for_ (const _u_ of users) {
          
    let_ _uniqueId_ _= _nanoid_()
    _await_ _prisma.user.update_({
            
    where: { id: parseInt(_u._id) },
            
    data: {
              
    reference_code: uniqueId +
    -${_u._username}` + 
    -${_u._id}
    ,
    Copy code
    },
    Copy code
    })`     
    }
    _await_ _prisma.$transaction_([users])
    Actually I want to update each user's reference_code ,for which I need its id and username. How to access the id and username of the user which im currently updating? From the docs I read that its not possible to grab id from find and the use it in update query. How can I solve this?
    r
    • 2
    • 3
  • h

    Harun

    05/31/2021, 10:57 AM
    Hi guys, not exactly Prisma related, but quick question, hope its okay. When using refresh-tokens for authentication, should i renew the refreshtoken upon renewing accesstoken?
    b
    • 2
    • 1
  • d

    Daniel Olavio Ferreira

    05/31/2021, 11:02 AM
    Hey @Harun, I can't say for sure, since I usually use an auth service, like firebase auth or supabase auuth, etc. But I'd say yes
  • d

    Daniel Olavio Ferreira

    05/31/2021, 11:03 AM
    There might be some security reasons behind it, but I'm probably no the best person to help you with that
    h
    • 2
    • 2
  • a

    Albert Luft

    05/31/2021, 2:26 PM
    Hi 🙂, very new Prisma user here, I really like the Project so far (only ORM that could generate proper types)! I have a question on how to create a many to many relationship with having a
    mult-field id
    : I have two tables,
    generic_articles
    and
    translations
    . Multiple articles can have the same name, so
    generic_article_name
    is not
    @unique
    , and one
    generic_article_name
    returns all translations for that name, making it a many to many relationship.
    Copy code
    model generic_articles {
      generic_article_id                                      Int                                                       @id
      generic_article_name                                    Int                                                       
      generic_article_names                                   generic_article_names[]
    }
    
    
    model translations {
      term_id          Int
      language_id      Int
      term             String             @db.VarChar(60)
      generic_articles generic_article_names[]
    
      @@id([term_id, language_id])
    }
    
    
    model generic_article_names {
      generic_article    generic_articles @relation(fields: [generic_article_id], references: [generic_article_name])
      generic_article_id Int
      translation        translations     @relation(fields: [term_id], references: [term_id])
      term_id            Int
    
      @@id([generic_article_id, term_id])
    }
    I tried following this, but it didn't work out as it needs to reference
    @id
    , but the
    generic_article_name
    is not unique. Currently I "pretend" for it to be unique and then I find duplicates of the
    generic_article_name
    and put the data manually onto the duplicates.
    r
    d
    • 3
    • 5
  • d

    Daniel Esteves

    05/31/2021, 3:21 PM
    Let's see if i could get to Ambassador 🙊
    🍀 3
    🤞 2
  • b

    Bruno Casado

    05/31/2021, 5:43 PM
    hello guys. I'm trying start my application (TS) but i'm facing some issues. I've migrated from 2.12 to the last version and generated the client without problems. But now, the below image shows errors related with the client. Someone have any idea why this?
    • 1
    • 1
  • j

    jasci

    05/31/2021, 8:13 PM
    Hello everybody, quick question: When you specify argument
    fields
    on
    relation
    attribute it should refer to the name of the field in the database or in the prisma schema ( if I use
    @map
    on some field, therefore different names in the db and 'schema.prisma' file and want to use it in
    fields
    ) ?
    Copy code
    @relation(fields: [someFieldName], references: [id])
    someFieldName
    - field name from 'schema.prisma' or actual db field's name ? Thank you.
    o
    r
    • 3
    • 3
  • v

    Vignesh

    05/31/2021, 8:40 PM
    How to translate this query to prisma?
    Copy code
    SELECT id, name from posts where id IN (select post_id from comments where user_id='123');
    o
    r
    • 3
    • 6
  • r

    Ramzi Tannous

    05/31/2021, 10:32 PM
    Hi @here what is the best way to generate graphql types from prisma schema?
    r
    • 2
    • 1
  • t

    Tharshan

    05/31/2021, 10:41 PM
    How does everyone handle seed data? and doing lots of prisma calls, often in a loop.
    o
    • 2
    • 2
  • t

    Tharshan

    05/31/2021, 10:41 PM
    Do you use something like
  • t

    Tharshan

    05/31/2021, 10:42 PM
    Copy code
    await products.data.map(async (product) => {
        const productData = {
          id: product.id,
          active: product.active,
          name: product.name,
          description: product.description,
          image: product.images?.[0] ?? null,
          metadata: product.metadata,
        }
        await db.product.upsert({
          where: { id: productData.id },
          update: productData,
          create: productData,
        })
        console.log(`Product inserted/updated: ${product.id}`)
      })
  • t

    Tharshan

    05/31/2021, 10:42 PM
    How about nested loops? whats the best way to write them?
    r
    • 2
    • 2
  • g

    Giorgio Delgado

    06/01/2021, 1:48 AM
    So how do I convert these intense Rust erorrs into something usable?
    Copy code
    Error occurred during query execution:
    
    ConnectorError(ConnectorError { user_facing_error: Some(KnownError { message: "Unique constraint failed on the constraint: `PRIMARY`", meta: Object({"target": String("PRIMARY")}), error_code: "P2002" }), kind: UniqueConstraintViolation { constraint: Index("PRIMARY") } })
    o
    r
    j
    • 4
    • 7
  • s

    Sai Raj

    06/01/2021, 4:27 AM
    I am facing this issue, that I have a route in express at which prisma throws this error, but even if I remove the route it just throws this particular error, it doesn't matter if I rewrite the controller of that particular route it just throws this error which is pretty invalid that I am passing a Float and expected is Int I have no idea what the error is saying, HELP
    r
    • 2
    • 15
  • c

    Christian Kozalla

    06/01/2021, 6:45 AM
    I have a question related to my Prisma Schema. Basically, I have a one-to-many relation between "Team" and "User", but I want "Team" to list the userIds only. Not the whole Array of users like User[] . The screenshot illustrates the existing solution where "Team" list an Array of Users[]. How can I only reference the userIds?
    r
    • 2
    • 2
  • r

    RemiO

    06/01/2021, 8:30 AM
    Hello, is it expected to get a different exception for a delete or update when it is wrapped in a transaction? Without the transaction I get a PrismaClientKnownRequestError with the code P2025, so it is easy to test. With the transaction I don't.
  • j

    jasci

    06/01/2021, 8:36 AM
    Hello everyone, currently upgrading from prisma1 to prisma2, specifically manually reviewing shema after the last step of the upgrade CLI(adding attributes, etc) Cannot quite understand the last step of the upgrade CLI, specifically refactoring of the relation attributes Foreign key's name in the DB -
    parentSalesDomain
    How model looks before the last step of the upgrade CLI
    Copy code
    model Calendar {
      id                String          @id @default(cuid()) @db.VarChar(30)
      ...
      parentSalesDomain String?         @db.VarChar(30)
      SalesDomain       SalesDomain?    @relation(fields: [parentSalesDomain], references: [id])
      ...
    }
    How model looks after the last step of the upgrade CLI
    Copy code
    model Calendar {
      id                  String          @default(cuid()) @id @db.VarChar(30)
      ...
      parentSalesDomainId String?         @map("parentSalesDomain") @db.VarChar(30)
      parentSalesDomain   SalesDomain?    @relation(fields: [parentSalesDomain], references: [id])
      ...
    }
    I cannot quite understand: 1. Is it allowed for the
    fields
    field of the
    relation
    attribute to reference itself ? 2. What is the role of the
    @map
    attribute here ? We map it to the underlying foreign key and then don't use this field in the
    relation
    What I think it should look like. I'm gonna use the new schema to create a new db from it, so I can rename fields(foreign key before - parentSalesDomain, foreign key now - parentSalesDomainId). Is it the right model definition?
    Copy code
    model Calendar {
      id                  String         @id @default(cuid()) @db.VarChar(30)
      ...
      parentSalesDomainId String         @db.VarChar(30)
      parentSalesDomain   SalesDomain    @relation(fields: [parentSalesDomainId], references: [id])
      ...
    }
    Thank you. P.S. prisma1 schema
    Copy code
    type Calendar {
      id: ID! @id
      ...
      parentSalesDomain: SalesDomain!
      ...
    }
    n
    • 2
    • 2
  • h

    Harun

    06/01/2021, 10:03 AM
    Hi guys, for those who is using nextjs, do you use next-auth?
    m
    o
    p
    • 4
    • 17
1...436437438...637Latest