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

    Bernardo Santos

    09/07/2022, 5:44 PM
    Hey! When creating a User in your db, if we have a Default User type, and then we have lets say AdminUser, and ClientUser, do we use two 1 to 1 optional relations? Or is there any better way, because having 2 optional relations would mean that a User could be both, could be either or could be none, but in theory it should be exclusively one type of User
    âś… 1
    h
    • 2
    • 3
  • j

    Joshua

    09/07/2022, 7:29 PM
    I've installed the
    opentelemetry-instrumentation-prisma-client
    package and it seems like it's broken stuff
  • j

    Joshua

    09/07/2022, 7:31 PM
    I'm running Prisma
    3.11.1
    - granted it's not 4.X but it's above the specified 3.8 in the docs
    đź‘€ 1
    h
    • 2
    • 1
  • y

    Yunbo

    09/07/2022, 7:34 PM
    say there's user table in prisma codebase return type of
    prisma.user.findMany
    is
    CheckSelect<T, PrismaPromise<Array<User>>, PrismaPromise<Array<UserGetPayload<T>>>>
    what could be the example object of this?
    Copy code
    const mockUser = {
      findMany = () => Promise.resolve([{id:1, name:"test user"}]);
    }
    this is saying return type is invalid. I was looking at https://www.prisma.io/docs/guides/testing/unit-testing documentation. but i'm using
    nestjs
    and trying to use golevelup/nestjs-testing package
    đź‘€ 1
    h
    v
    • 3
    • 6
  • c

    Chip Clark

    09/07/2022, 8:52 PM
    Prisma and NodeJS 16.17.0 - I get an error when I attempt to run
    Copy code
    npm i prisma@4 --save
    This works fine with NodeJS v14.17 - Since system requirements say Node.js14.17.X / 16.X, this should work. Here is the error log:
    Copy code
    0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
    1 info using npm@8.15.0
    2 info using node@v16.17.0
    3 timing npm:load:whichnode Completed in 0ms
    4 timing config:load:defaults Completed in 3ms
    5 timing config:load:file:C:\Users\tech-cclark\AppData\Roaming\nvm\v16.17.0\node_modules\npm\npmrc Completed in 1ms
    6 timing config:load:builtin Completed in 2ms
    7 timing config:load:cli Completed in 3ms
    8 timing config:load:env Completed in 2ms
    9 timing config:load:file:C:\Sites\AM-API-MDD\.npmrc Completed in 0ms
    10 timing config:load:project Completed in 3ms
    11 timing config:load:file:C:\Users\tech-cclark\.npmrc Completed in 0ms
    12 timing config:load:user Completed in 0ms
    13 timing config:load:file:C:\Program Files\nodejs\etc\npmrc Completed in 0ms
    14 timing config:load:global Completed in 0ms
    15 timing config:load:validate Completed in 0ms
    16 timing config:load:credentials Completed in 2ms
    17 timing config:load:setEnvs Completed in 2ms
    18 timing config:load Completed in 18ms
    19 timing npm:load:configload Completed in 19ms
    20 timing npm:load:mkdirpcache Completed in 1ms
    21 timing npm:load:mkdirplogs Completed in 0ms
    22 verbose title npm i prisma@4
    23 verbose argv "i" "prisma@4" "--save"
    24 timing npm:load:setTitle Completed in 2ms
    25 timing config:load:flatten Completed in 5ms
    26 timing npm:load:display Completed in 9ms
    27 verbose logfile logs-max:10 dir:C:\Users\tech-cclark\AppData\Local\npm-cache\_logs
    28 verbose logfile C:\Users\tech-cclark\AppData\Local\npm-cache\_logs\2022-09-07T20_47_04_581Z-debug-0.log
    29 timing npm:load:logFile Completed in 12ms
    30 timing npm:load:timers Completed in 0ms
    31 timing npm:load:configScope Completed in 0ms
    32 timing npm:load Completed in 45ms
    33 verbose stack C:\Users\tech-cclark\AppData\Roaming\nvm\v16.17.0\node_modules\npm\node_modules\libnpmfund:1
    33 verbose stack ../workspaces/libnpmfund
    33 verbose stack ^
    33 verbose stack
    33 verbose stack SyntaxError: Unexpected token '.'
    33 verbose stack     at Object.compileFunction (node:vm:360:18)
    33 verbose stack     at wrapSafe (node:internal/modules/cjs/loader:1055:15)
    33 verbose stack     at Module._compile (node:internal/modules/cjs/loader:1090:27)
    33 verbose stack     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    33 verbose stack     at Module.load (node:internal/modules/cjs/loader:1004:32)
    33 verbose stack     at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    33 verbose stack     at Module.require (node:internal/modules/cjs/loader:1028:19)
    33 verbose stack     at require (node:internal/modules/cjs/helpers:102:18)
    33 verbose stack     at Object.<anonymous> (C:\Users\tech-cclark\AppData\Roaming\nvm\v16.17.0\node_modules\npm\lib\utils\reify-output.js:16:38)
    33 verbose stack     at Module._compile (node:internal/modules/cjs/loader:1126:14)
    34 verbose cwd C:\Sites\AM-API-MDD
    35 verbose Windows_NT 10.0.17763
    36 verbose node v16.17.0
    37 verbose npm  v8.15.0
    38 error Unexpected token '.'
    39 verbose exit 1
    40 timing npm Completed in 87ms
    41 verbose code 1
    42 error A complete log of this run can be found in:
    42 error     C:\Users\tech-cclark\AppData\Local\npm-cache\_logs\2022-09-07T20_47_04_581Z-debug-0.log
    h
    • 2
    • 1
  • w

    William GM

    09/07/2022, 11:12 PM
    Hello Has the team had any devopment with this issue? https://github.com/prisma/prisma/issues/14918
    âś… 1
    r
    • 2
    • 1
  • d

    Dhwanik Panchal

    09/08/2022, 5:25 AM
    Hello. We have deployed our Node.js application on AWS ECS, with AWS RDS for MySQL. We have not tuned the
    connection_limit
    parameter, nor any other parameters. We accepted the default ones. Our ECS instance has 0.5 cores available with one instance (in the development environment), hence, the connection limit would be
    2 * 0.5 + 1 = 2
    for our instance. However, while monitoring RDS, we notice a warning in our database. Here's what the warning said:
    [Warning] Aborted connection xxx to db: '<database name>' user: '<user name>' host: '<host IP>' (Got an error reading communication packets)
    I hope the given information is sufficient to know about the problem we are facing. Otherwise, I am happy to share more details if required. Thanks!
    h
    v
    • 3
    • 4
  • r

    Rune Jørgensen

    09/08/2022, 6:59 AM
    Hi 👋! I'm very excited about the comming multi-schema support! Will it work with the pull command though 🙂?
    âś… 1
    h
    • 2
    • 2
  • v

    Vasily Zorin

    09/08/2022, 8:41 AM
    It would be nice to create a channel for #cockroachdb
    âś… 1
    n
    • 2
    • 1
  • r

    Raphael Etim

    09/08/2022, 11:55 AM
    Hi @Jaruwat Thongchana đź‘‹ You will need to carry out a down migration. See the guide on how to do that here
  • m

    Mohammed Almajid

    09/08/2022, 11:59 AM
    not sure if mongodb channel is active so sorry for sharing here again
  • o

    OffBy0x01

    09/08/2022, 1:49 PM
    Hello all, does anyone happen to know how to add boolean filters to prisma studio? I've tried just about every truthy-value I can think of and I just cannot get them to work - the value box always shows as red.
    đź‘€ 1
    n
    • 2
    • 2
  • r

    Robin Irmer

    09/08/2022, 3:37 PM
    Hi all, I am trying to execute a rawQuery that contains parameters. As soon as I submit this query, I get the following error message. I want to develop a global search with the rawQuery, for this I use tsvectoren in a postgres database. Has anyone had the same problem and can help me?
    Copy code
    const value = 'test';
    const results = await prismaClient.$queryRaw`
        SELECT * FROM "contact"
        WHERE "textSearch" @@ to_tsquery('english', '${query}')
        ORDER BY ts_rank("textSearch", to_tsquery('english', '${query}')) DESC
        LIMIT 10;
      ;`;
    Copy code
    PrismaClientKnownRequestError: 
    Invalid `prisma.queryRaw()` invocation:
    
    
      Your raw query had an incorrect number of parameters. Expected: `0`, actual: `2`.
        {
      code: 'P1016',
      clientVersion: '3.0.2',
      meta: { expected: 0, actual: 2 }
    }
    đź‘€ 1
    r
    • 2
    • 6
  • r

    Rob

    09/08/2022, 4:07 PM
    Hi everyone, I notice when I change a certain part of my schema, prisma goes ahead and wipes all of my schema. I have two tables, user and options. When I changed things in 'options', then did prisma push, It asked to clear everything since there were contradictions in the schema. I assumed clearing everything meant just the 'options' table, but I also noticed my 'users' table was gone as well. It's not a big deal since this isn't production, but what could be done to prevent this?
    âś… 1
    r
    • 2
    • 6
  • b

    Bryan Z

    09/08/2022, 6:16 PM
    Hi, does anyone have experience using Prisma with React Query? I'm calling
    const { data, error, isLoading } = useQuery(['links'], resolvers.Query.links)
    Where
    resolvers.Query.links
    is
    links: async () => prisma.link.findMany()
    I'm getting the error
    Copy code
    Invalid environment variables:
     DATABASE_URL: Required
     NODE_ENV: Required
    But DATABASE_URL is specified in the root .env file. Previously I was using Apollo Client and didn't encounter this issue.
    đź‘€ 1
    p
    r
    a
    • 4
    • 13
  • j

    Jon Ramvi

    09/08/2022, 7:28 PM
    How can I store a pointer to one of the elements in a relation array so that the Prisma client will work well with it? Example: https://pastebin.com/JZCEA5X2
    âś… 1
    h
    • 2
    • 1
  • j

    Jon Ramvi

    09/08/2022, 7:33 PM
    I guess it's more of an ORM design pattern question…
  • d

    David Wagner

    09/08/2022, 10:33 PM
    Hello all, I'm following along here https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/querying-the-database-typescript-postgres and encountered an error. When trying to create a new user I get a DB Error response "Integer out of range for type int(4)". I'm just learning this and not sure how to troubleshoot this one. Any help would be much appreciated.
    âś… 1
    r
    • 2
    • 5
  • c

    Clément Guibout

    09/08/2022, 10:42 PM
    Hello everyone I have been losing my mind on a problem recently I have two models such as:
    Copy code
    model Event {
      evt_id           String        @id @default(uuid())
      evt_title        String        @db.VarChar(100)
      evt_content      String        @db.VarChar(1024) @default("Cet événement n'a pas encore de description.")
      evt_picture      String?       @db.VarChar(1024) @default("/img/events/default.png") // Local path
      evt_likeCount    Int           @default(0)
      evt_beginDate    DateTime
      evt_endDate      DateTime
      evt_participants User[]
      evt_created_at   DateTime      @db.Timestamp() @default(now())
      evt_updated_at   DateTime      @updatedAt
      evt_isVerified   Boolean
    }
    
    model User {
      usr_id                     String            @id @default(cuid())
      usr_token                  String            @db.VarChar(1024) @unique
      usr_name                   String?           @db.VarChar(100)
      usr_nickname               String?           @db.VarChar(32) @unique
      usr_email                  String            @db.VarChar(100) @unique
      usr_profilePicture         String?           @db.VarChar(1024) @default("/img/users/default.png") // Local path
      usr_events                 Event[]
      usr_createdAt              DateTime          @db.Timestamp @default(now())
    }
    I created my database etc using npx prisma generate, and I have no migration in this project But when accessing the studio, I get the error: ``The table
    public._EventToUser
    does not exist in the current database.`` Oh boy I don't understand from where this could even come from... Could someone indicate me the path? I feel like this is an internal thing for prisma, but cannot find anything......
    r
    a
    • 3
    • 18
  • o

    Omri Katz

    09/08/2022, 11:07 PM
    Anyone how I can get db.Timestamp and unix epoch timestamp and not a string?
    đź‘€ 1
    p
    r
    v
    • 4
    • 7
  • o

    Omri Katz

    09/08/2022, 11:07 PM
    I want unix timestamp and not date and time
  • n

    nguyễn thiện

    09/09/2022, 3:25 AM
    hi, i started with prisma in a few day and i realized that all the prisma model is in a file. Is there any way to support for splitting prisma model into multiple file?
    âś… 1
    j
    r
    d
    • 4
    • 6
  • f

    Florian

    09/09/2022, 7:20 AM
    Hi, does the documentation website work on your side? I seem to have an HTTP500 when requesting https://www.prisma.io/docs/concepts/components/prisma-client/middleware
    âś… 1
    r
    • 2
    • 2
  • i

    Ilkka Huotari

    09/09/2022, 9:25 AM
    A lot of people (including me) are waiting for Postgres composite types support in Prisma (https://www.postgresql.org/docs/current/rowtypes.html). There is a GitHub issue for them (https://github.com/prisma/prisma/issues/4263). This shouldn't be a big problem as it's supported by Postgres natively?
    âś… 1
    r
    • 2
    • 1
  • t

    Taylor Lindores-Reeves

    09/09/2022, 9:52 AM
    Hello guys, I have Question… Is it possible to set PostGres DateTime 24 hours ahead of a relative Prisma model field?
  • t

    Taylor Lindores-Reeves

    09/09/2022, 9:52 AM
    So let’s say I have a field that is createdAt, and that is by default now, can I set a field that is 24hoursAheadOfCreatedAt directly within the Prisma schema?
  • t

    Taylor Lindores-Reeves

    09/09/2022, 9:57 AM
    Looks like I can use the dbgenerated function?
    r
    • 2
    • 4
  • t

    Taylor Lindores-Reeves

    09/09/2022, 10:05 AM
    Yeah so looks like it’d look like this in the prisma schema:
    24hoursAheadOfCreatedAt @default(dbgenerated("NOW() + interval '1 day'")))
    r
    • 2
    • 1
  • o

    Omri Katz

    09/09/2022, 10:12 AM
    how can I use class-transformer with Prisma?
    âś… 1
    r
    • 2
    • 1
  • n

    Nicholas Ewing

    09/09/2022, 12:51 PM
    What's a man got to do to get ya'll on Discord?
    âś… 1
    n
    • 2
    • 1
1...618619620...637Latest