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

    Jacob Duval

    08/15/2022, 11:07 PM
    Hi team! I'm trying to port a ruby codebase over to node + prisma. I'm having trouble replicating this functionality though
    Copy code
    ActiveRecord::Base.connection.execute(
          <<-SQL
            SET "hasura.user" = '#someuser'
          SQL
        )
    How can I inject this sort of behaviour into prisma? Or is it just not possible?
    ✅ 1
    n
    • 2
    • 1
  • h

    Hussam Khatib

    08/16/2022, 6:02 AM
    Hey Prisma Team, Do you why does prisma rawquery not work when I'm passing a variable. This wokrs if the variable is a number, but anything inside quotes is not working. Example from docs
    Copy code
    const email = '<mailto:emelie@prisma.io|emelie@prisma.io>'
    const result = await prisma.$queryRaw`SELECT * FROM User WHERE email = ${email}`
    This would not work as
    email
    is enclosed in qoutes. It would work if
    const email = 2
    for example DB : mySql
    ✅ 1
    👀 1
    r
    • 2
    • 6
  • c

    Christoffer

    08/16/2022, 7:53 AM
    hi, why does findMany disappear from the client API for my model when I add a multiple field @@unique?
    Copy code
    @@unique([user_id, auth_type])
    👀 1
    r
    v
    • 3
    • 2
  • c

    Christoffer

    08/16/2022, 7:53 AM
    neither user_id or auth_type is unique on their own
  • d

    Derock

    08/16/2022, 1:23 PM
    Prisma is silently crashing when it tries to connect to the database. (
    prisma.$connect()
    or any primsa query) Commands like
    prisma db push
    work perfectly fine in the same environment.
  • d

    Derock

    08/16/2022, 1:23 PM
    https://hastebin.com/gixijopawa
  • d

    Derock

    08/16/2022, 1:24 PM
    logs when
    DEBUG=*
    env is set
  • d

    Derock

    08/16/2022, 1:24 PM
    This crashes my entire application with no errors in console.
  • d

    Derock

    08/16/2022, 1:24 PM
    any ideas on how to debug this issue?
    ✅ 1
    n
    • 2
    • 2
  • i

    Italo Gama

    08/16/2022, 2:52 PM
    Anyone?
    👀 1
    m
    n
    a
    • 4
    • 19
  • r

    Robert Lee

    08/16/2022, 6:10 PM
    I tried searching this channel but haven't found any good solutions to dealing with vercel's preview branches & having multiple databases. Do y'all set up staging database branches and force push to staging branches in order to test out changes in a QA environment? Otherwise, multiple devs with different branches pushing to the preview
    DATABASE_URL
    will all have migration errors. Anyone have a solid creative solution to this besides force pushing to staging branches w/ specific `DATABASE_URL`s defined to them?
    👀 2
    c
    n
    • 3
    • 5
  • t

    Taylor Cantwell

    08/17/2022, 2:24 AM
    Hi guys, I’m trying to update two tables at once. Except when I add the linked table: user --> update, I’m getting a type error that roleId should be undefined. However, if I remove the update to the linked table, the type error disappears and roleId correctly expects a string. Does anyone know what I’m doing wrong here?
    Copy code
    data: {
            roleId: 'UEET',
            user: {
              update: {
                ...rest,
              },
            },
          },
    👀 1
    r
    • 2
    • 2
  • e

    Enzot

    08/17/2022, 11:17 AM
    Hi, I cannot find in documentation how to connect to AWS database using secrets?
    👀 1
    a
    v
    • 3
    • 2
  • b

    Bastien Etienne

    08/17/2022, 1:48 PM
    Hello , i have a little question so, is it possible to add data when i create table (npx db push)
    ✅ 1
    a
    r
    • 3
    • 3
  • b

    Benjamin FROLICHER

    08/17/2022, 2:06 PM
    Hi 🤘 I have follow this article to be able to use multiple .env files, but that doesn't works. https://www.prisma.io/docs/guides/development-environment/environment-variables/using-multiple-env-files i use prisma with nestjs.
    Copy code
    "start:dev": "dotenv -e ./.env.local -- nest start --watch",
    When lauching
    Copy code
    npm start run:dev
    I have the following error
    Copy code
    Error: error: Environment variable not found: DATABASE_URL.
      -->  schema.prisma:10
       | 
     9 |   provider = "postgresql"
    10 |   url      = env("DATABASE_URL")
       |
    Working solution :
    Copy code
    dotenv -e .env.local -- npm start run:dev
    Do you have an idea ?
    👀 1
    r
    • 2
    • 4
  • a

    Arpit Satyal

    08/17/2022, 2:17 PM
    hello guys!! can anyone help me with this problem? please!!! https://stackoverflow.com/questions/73389837/prisma-not-assignable-to-type-error-on-trying-to-update-a-field
    ✅ 1
    d
    r
    • 3
    • 4
  • s

    Slackbot

    08/17/2022, 3:47 PM
    This message was deleted.
    r
    • 2
    • 1
  • t

    Ted Joe

    08/17/2022, 5:04 PM
    When creating models, I want all my models to have certain fields such as
    createdAt
    ,
    updatedAt
    ,
    deletedAt
    , etc. Do I have to manually create them on every field or is there a place in prisma I can add it once, and have it add on every model?
    👀 1
    a
    v
    • 3
    • 2
  • v

    Vivek Poddar

    08/17/2022, 5:57 PM
    Posting in general, I am getting the following error on AWS lambda deploy.
    Copy code
    {
      "errorType": "Error",
      "errorMessage": "@prisma/client did not initialize yet. Please run \"prisma generate\" and try to import it again.\nIn case this error is unexpected for you, please report it in <https://github.com/prisma/prisma/issues>",
      "stack": [
        "Error: @prisma/client did not initialize yet. Please run \"prisma generate\" and try to import it again.",
        "In case this error is unexpected for you, please report it in <https://github.com/prisma/prisma/issues>",
        "    at new PrismaClient (/var/task/node_modules/.prisma/client/index.js:3:11)",
        "    at Object.<anonymous> (/var/task/index.js:90:10)",
        "    at Module._compile (internal/modules/cjs/loader.js:1085:14)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
        "    at Module.load (internal/modules/cjs/loader.js:950:32)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
        "    at Module.require (internal/modules/cjs/loader.js:974:19)",
        "    at require (internal/modules/cjs/helpers.js:101:18)",
        "    at _tryRequireFile (/var/runtime/UserFunction.js:71:32)",
        "    at _tryRequire (/var/runtime/UserFunction.js:159:20)"
      ]
    }
    ✅ 1
    n
    • 2
    • 1
  • v

    Vivek Poddar

    08/17/2022, 5:58 PM
    I can see my CI/CD generates prisma client.
    ✅ 1
    n
    • 2
    • 4
  • a

    Alban Kaperi

    08/17/2022, 6:11 PM
    Hi all, I am trying to make the sum of some culmns but without success, here is the idea:
    Copy code
    const customers = await prisma.employee.findMany({
        include: {
            workingHours: true,
        },
    })
    output:
    Copy code
    [
        {
            "id": 1,
            "name": "beth",
            "surname": "halvorson",
            "gender": "Female",
            "email": "<mailto:bethhalvorson@gmail.com|bethhalvorson@gmail.com>",
            "phone": "501-945-084",
            "code": "kn7v6",
            "points": 12941,
            "workingHours": [
                {
                    "id": 1,
                    "normalTime": 7,
                    "overTime": 1,
                    "doubleTime": 1,
                    "vacationTime": 0,
                    "sickTime": 0,
                    "employeeId": 1,
                },
                {
                    "id": 2,
                    "normalTime": 4,
                    "overTime": 3,
                    "doubleTime": 1,
                    "vacationTime": 0,
                    "sickTime": 0,
                    "employeeId": 1,
                },
            ]
        },
    ]
    I want to change the query to receive smth like this:
    Copy code
    [
        {
            "id": 1,
            "name": "beth",
            "surname": "halvorson",
            "gender": "Female",
            "email": "<mailto:bethhalvorson@gmail.com|bethhalvorson@gmail.com>",
            "phone": "501-945-084",
            "code": "kn7v6",
            "points": 12941,
            "_sum": {
                "totalHours": 18,
            },
        },
    ]
    where _sum: is the total of all columns(normalTime, overTime, vacationTime, sickTime) I didn't want to use javascript methods to achieve that
    ✅ 1
    👀 2
    a
    • 2
    • 6
  • o

    Omar

    08/17/2022, 8:11 PM
    Hello Prisma, Any idea why the args of mongodb raw queries operations are under
    outputObjectTypes
    and not under
    inputObjectTypes
    like all other operations?
    ✅ 1
    n
    • 2
    • 7
  • o

    Okan Yıldırım

    08/17/2022, 8:41 PM
    Hello, I get an error like this `Unique constraint failed on the constraint: `PersonalData_userId_key`` but I don’t know why. It is the current relationship.
    _model_ User {
    personalData _PersonalData_?
    }
    model PersonalData {
    user   _User_ @relation(_fields_: [userId], _references_: [id], _onDelete_: Cascade, _onUpdate_: Cascade)
    userId _Int_  @unique
    }
    ✅ 1
    👀 1
    n
    • 2
    • 4
  • a

    Alejandro Diaz

    08/17/2022, 8:47 PM
    Hey everyone! I have this issue with many to many relationship. My question is why when implicit, it creates only 1 relation if the tables are named survey and question the created table is _SurveyToQuestion but I don't see the _QuestionToSurvey table. Is there something I'm confusing? In that case sorry for my ignorance, but in my specific scenario a survey can have many questions and a question can be in many surveys. Thanks for your help
    ✅ 1
    n
    • 2
    • 2
  • r

    Richard Kaufman-López

    08/17/2022, 9:33 PM
    I’ve been reading the softdelete middleware example. It’s great! See https://www.prisma.io/docs/concepts/components/prisma-client/middleware/soft-delete-middleware I have a follow up question someone here may know the answer too: Would this also block a query like
    prisma.user.findMany({ select: { posts: true } })
    from returning a soft-delete post?
    ✅ 1
    m
    n
    • 3
    • 3
  • w

    will

    08/17/2022, 9:43 PM
    Hey everyone, do you guys know hot to use Full text search with Spanish language ?
    ✅ 1
    👀 1
    n
    • 2
    • 2
  • s

    Santi Buenahora

    08/17/2022, 10:00 PM
    Hi all! Is there any way to convert a
    Prisma.ProductWhereInput
    into a raw WHERE statement? Or to get the SQL for a call like
    prisma.product.find_many({ where })
    ?
    👀 1
    ✅ 1
    n
    • 2
    • 1
  • g

    Guillermo David

    08/17/2022, 10:05 PM
    Hey folks, I'm using prism search, for the search in 2 columns of my table, firstName and lastName, but it gives me an error when I search for the same string in both fields.
    Copy code
    where: {
            firstName: { search: 'word' },
            lastName: { search: 'word' },
          } // this is an error
    but when I try to use differents string in the firstName and lastname is correct the function
    ✅ 1
    n
    • 2
    • 2
  • a

    Almog Baku

    08/18/2022, 6:19 AM
    Hi, how can I use a custom query for the Where clause?
  • a

    Almog Baku

    08/18/2022, 6:21 AM
    I need to do some manipulation on the field before comparison:
    Copy code
    SELECT <fields> FROM <db.table> WHERE regexp_replace(mobile_phone, '[^\w]', 'g') = <value>
    👀 1
    n
    v
    • 3
    • 2
1...609610611...637Latest