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

    GN Vageesh

    04/14/2022, 5:08 PM
    i am new to prisma... so sorry if that's a bad question 😅
  • c

    Chris Gurba

    04/14/2022, 5:39 PM
    what’s the best channel for postgres questions?
    • 1
    • 1
  • y

    yujonglee

    04/15/2022, 5:13 AM
    I heard that Prisma was more like graphql-thing in the past. Is this true? Is there any links or terms that I can understand the history of Prisma's development?
    a
    • 2
    • 1
  • o

    Oleg Rudak

    04/15/2022, 7:58 AM
    Hello everyone I have model Posts (f.e.) In this model there is field published - boolean Is it possible to get count of published and not published posts? thank you! EDIT: I need smth like this:
    Copy code
    SELECT published, COUNT(*) FROM Posts GROUP BY published
    EDIT 2: I need this, but in relation:
    Copy code
    const data = await prisma.posts.groupBy({
            by: ["published"],
            _count: {
              published: true,
            },
          });
    n
    • 2
    • 1
  • s

    shahrukh ahmed

    04/15/2022, 12:42 PM
    Hi, I used
    npx prisma generate
    with a output directory provided in the Schema. My
    package.json
    is configured with
    "type": "module"
    . This import doesn't quite work.
    Copy code
    import { PrismaClient }  from '../../prisma-client/index.js' 
    let prisma = new PrismaClient();```
    The error I get even when running
    node --experimental-specifier-resolution=node server.js
    is
    The requested module '../../prisma-client/index.js' does not provide an export named 'PrismaClient'
    a
    • 2
    • 1
  • a

    Alf Fenton

    04/15/2022, 2:02 PM
    Hello, everyone at Prisma. Thanks for allowing a direct audience with your team through slack. I'm a developer working on a startup project using prisma, nextjs, and MongoDB; and in this project, I have a many to many self relational database models for my users. (seen below)
    Copy code
    model User {
      id            String    @id @default(auto()) @map("_id") @db.ObjectId
      email         String    @unique
      description   String?
      name          String?
      username      String?
      password      String?
      followedBy    User[]    @relation("UserFollows", fields: [followedByIDs], references: [id])
      followedByIDs String[]  @db.ObjectId
      following     User[]    @relation("UserFollows", fields: [followingIDs], references: [id])
      followingIDs  String[]  @db.ObjectId
      role          Role      @default(USER)
      reivews       Review[]
      emailVerified DateTime? @map("email_verified")
      image         String?
      accounts      Account[]
      sessions      Session[]
      @@fulltext([name(sort: Desc), username, email])
      @@map("users")
    }
    When attempting to match/connect two existing users through the following relations with the use of Prisma client code:
    Copy code
    await prisma.user.update({
                where:{
                    email:'<mailto:alf@votaryfilms.com|alf@votaryfilms.com>'
                },
                data:{
                    following: {connect: [{id: data}]}
                }
            })
    I get the following error:
    Copy code
    The current database provider doesn't support a feature that the query used: Unhandled and unsupported value
    mapping for MongoDB: 6223c13a26bb3d44fc98dad5 as Int.
    If possible, could someone help point out where I'm wrong in my approach, if this is a bug perhaps, or if there are better-known ways for me to achieve the above goal? Thanks so much 🙏
    j
    • 2
    • 1
  • k

    Kenneth Gitere

    04/16/2022, 7:11 AM
    Hi guys, are there any resources on deploying an app using prisma on Netlify? I got my app to build with no problem but it throws a stacktrace when I open the app
    k
    n
    • 3
    • 2
  • v

    Victor Meireles

    04/16/2022, 6:00 PM
    People, how can I share types with an Angular front-end? I'm trying mono-repo, but can't migrate my Angular template.
    n
    • 2
    • 1
  • m

    Mischa

    04/17/2022, 9:55 AM
    I'd like to try implementing SAVEPOINT transactions for running integration tests in isolated transactions (see https://github.com/prisma/prisma/issues/9710) What I don't know how to do is replace all sql calls to
    BEGIN
    with
    SAVEPOINT
    (like pytest-sqlalchemy does) - is this possible to do while running my test? (edited)
    j
    • 2
    • 6
  • b

    Brothak

    04/17/2022, 9:09 PM
    How does connection pool work? If I have a postgres with 100 max_connections setting and pool size is set to 10, does it mean that I can only ever use 10 out 100 connections ? No right?
    j
    • 2
    • 3
  • b

    Brothak

    04/17/2022, 9:10 PM
    Reason I am asking is lets say I want to run 10 SELECTS concurently through prisma how would that work?
  • b

    Brothak

    04/17/2022, 10:01 PM
    Secondly I see a lot of ClientRead Idle connections in my postgres db. The query has been idle for 2 to 26 hours, wait_event is clientread. They are select which i run using queryRawUnsafe
    j
    • 2
    • 1
  • m

    mjyoung

    04/18/2022, 1:03 AM
    Do y'all take advantage of Postgres enums with prisma? I love the auto generated typescript types and how readable they are in the DB itself but I'm finding adding, renaming, removing values from a pg enum in a db with existing data to be a pain. Reconsidering reimplementing all my enums as tables I can foreign key to. Are enums only good for a set of values that I have a strong sense will basically never change? I should probably stop treating them like a basic typescript enum 😝
    y
    • 2
    • 1
  • l

    lorenzo xl gomez

    04/18/2022, 11:13 AM
    Hello, how do I filter by range? In prism ORM? Thanks in advance, regards.
    n
    • 2
    • 1
  • m

    Mykyta Machekhin

    04/18/2022, 12:08 PM
    Hy, guys. I have unexpected behaviour of prisma, when select
    _count
    field in findMany query. Project compiled without errors
    n
    • 2
    • 4
  • a

    Alfred Noland

    04/18/2022, 1:21 PM
    Hi, we are setting up Prisma to use in Production. In our dev we are preforming migrate dev --name init and when we deploy to prod in our start script in Node.js we have the prisma migrate deploy. But we are getting this error without any error logs: 3 migrations found in prisma/migrations Error: P3009 migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve [2022-04-18 125506] The
    20220413095619_init
    migration started at 2022-04-18 095258.950 UTC failed with the following logs: Does anyone has experience with this?
    y
    j
    • 3
    • 8
  • k

    Kadam Patel

    04/18/2022, 2:11 PM
    Hello I currently working on Prisma upgrading from Prisma 1 to prisma 2 and I have face many problem in upgrading that..due to upgrade CLI does not solve the all the problem..is there anyone can help?
    j
    • 2
    • 1
  • q

    Quentin Gilon

    04/18/2022, 2:42 PM
    HELP NEEDED - LOOKING FOR AN EXPERT PRISMA 1 Hi guys, we are having an issue re-importing our Database. The whole DB is in JSON but when re-importing this is the issue we get.
    Copy code
    "message": "TypeIdentifier not yet supported in Import as ID. com.prisma.shared.models.TypeIdentifier$Int$@4a2acc6c",
          "requestId": "eu1:cl24f25t66z6v09991kjjvzck"
    Our app is down and so is our design service. This is super time sensitive. Is there anyone with experience in Prisma 1 available to help (paid of course)? @Kevin Justal is our Lead Dev.
    v
    • 2
    • 1
  • r

    Richard

    04/18/2022, 2:48 PM
    alphabet yellow question NextJS app in monorepo is unable to locate
    schema.prisma
    (generated in a separate package in the same monorepo) Question What is the best way for me to setup the monorepo? Problem When I import prisma from the package in my
    web
    app, prisma is unable to locate the
    schema.prisma
    file:
    Copy code
    error - Error: ENOENT: no such file or directory, open '/Users/xxx/rootDir/apps/web/.next/server/pages/api/trpc/schema.prisma'
    This may be related to the following prisma issues: • https://github.com/prisma/prisma/issues/9435#issuecomment-1065879963 • https://github.com/prisma/prisma/issues/10512 (supposed to be fixed via #12427) Context • I have a monorepo setup with an
    apps/web
    nextJS app and a separate
    packages/database
    package with prisma inside. • The database package builds via tsup to
    packages/database/dist
    .
    Copy code
    apps/
    ├─ web/                          # <-- nextJS app (unable to detect schema)
    packages/
    ├─ database/
    │  ├─ prisma/                    # prisma setup
    │  │  ├─ schema.prisma
    │  ├─ src/
    │  │  ├─ client.ts               # exports PrismaClient & global.prisma type in prod
    │  │  ├─ index.ts                # exports from prisma client
    │  │  ├─ seed.ts                 # prisma seeding script for local dev
    │  ├─ .env.example               # `DATABASE_URL` env var
    │  ├─ tsup.config.js             # builds to /dist folder in this package
    h
    n
    m
    • 4
    • 7
  • i

    isaacs

    04/18/2022, 5:56 PM
    Is it possible to have complex relational criteria in a
    prisma.create
    ? I'm looking for the equivalent of:
    Copy code
    INSERT INTO membership(orgId, email, role)
    SELECT orgId, @email as email, @role as role
    FROM membership
    WHERE orgId = @orgId
      AND userId = @userId
      AND (role = 'OWNER' OR (role = 'ADMIN' AND @role = 'USER'));
    so you'd call it setting the
    userId
    to the current user taking the action, and this would assert that it would only create if the user has permission to add new users at the requested role (I know I can do
    prisma.findUnique
    to get the membership role of the current user, and then do it in javascript, but i try to avoid TOCTOU as a general practice.)
    n
    • 2
    • 3
  • y

    Yunbo

    04/18/2022, 6:59 PM
    is there any way to update existing migration folder name such as typo? ( ex. 20220101123_add_name_colm -> 20220101123_add_name_column )
    a
    • 2
    • 5
  • b

    Brothak

    04/18/2022, 7:19 PM
    I see a lot of ClientRead Idle connections in my postgres db. The query has been idle for 2 to 26 hours, wait_event is clientread. They are select which i run using queryRawUnsafe
    j
    • 2
    • 1
  • d

    daemon

    04/18/2022, 8:28 PM
    Hello there, I’m looking for some guidance. My CRUD works fine but in my resolvers i’m having some big messy type errors. Can someone point me somewhere please?
    Copy code
    Type '(_: {}, args: { name: string; }, ctx: Context) => Prisma__ExchangeClient<Exchange>' is not assignable to type 'FieldResolver<"Mutation", "addExchange">'.
      Type 'Prisma__ExchangeClient<Exchange>' is not assignable to type 'MaybePromise<{ id: string; name: string; } | null>'.
        Type 'Prisma__ExchangeClient<Exchange>' is not assignable to type 'PromiseLike<{ id: string; name: string; } | null>'.
          Types of property 'then' are incompatible.
            Type '<TResult1 = Exchange, TResult2 = never>(onfulfilled?: ((value: Exchange) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | null | undefined) => Promise<...>' is not assignable to type '<TResult1 = { id: string; name: string; } | null, TResult2 = never>(onfulfilled?: ((value: { id: string; name: string; } | null) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ... 1 more ... | undefined) => PromiseLike<...>'.
              Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
                Types of parameters 'value' and 'value' are incompatible.
                  Type 'Exchange' is not assignable to type '{ id: string; name: string; }'.
                    Types of property 'id' are incompatible.
                      Type 'number' is not assignable to type 'string'.ts(2322)
    r
    • 2
    • 4
  • d

    daemon

    04/18/2022, 8:31 PM
    Here is my
    schema.prisma
    and my
    schema.graphql
    Copy code
    //schema.prisma
    model Exchange {
      id   Int    @id @default(autoincrement())
      name String @unique
    }
    //schema.graphql
    type Exchange {
      id: ID!
      name: String!
    }
    
    type Mutation {
      addExchange(name: String!): Exchange
    }
    
    type Query {
      exchanges: [Exchange!]!
      hello: String
    }
  • d

    daemon

    04/18/2022, 8:34 PM
    Is there some type misalignment i’m not aware of?
    n
    • 2
    • 1
  • d

    daemon

    04/18/2022, 9:00 PM
    Is there any
    nexus-prisma
    example boilerplate project?
    n
    • 2
    • 1
  • y

    Yunbo

    04/18/2022, 10:18 PM
    Deleted - by author(me) because it's not prisma related
    i
    n
    • 3
    • 6
  • j

    Jonas Rothmann

    04/18/2022, 10:39 PM
    Prisma isn’t able to handle more than 999 requests at once. The actual model called is fine, but any relations within it are all null/empty arrays. Is this a known issue? It might be related to how it breaks up calls instead of using left join etc.
    d
    s
    +2
    • 5
    • 7
  • a

    Alouani Younes

    04/19/2022, 12:48 AM
    Dear community, How do you seed your database using an sql file ? the documentation doesn't explain what to change in the package.json for the command.
    n
    • 2
    • 1
  • b

    Ben Guthrie

    04/19/2022, 1:23 AM
    Imagine you're storing which videos are on which playlist (like Youtube). One requirement is that duplicate videos are allow, so instead of using
    playlistId
    and
    videoId
    as composite keys, you have a unique
    id
    on the model. If you had the `playlistId`/`videoId` pairs, but not the
    id
    s, is there an efficient method to find all of the rows for the pairs? (
    schema.prisma
    and data in thread)
    h
    n
    g
    • 4
    • 10
1...564565566...637Latest