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

    Ramesh

    06/27/2021, 9:10 AM
    We have added prisma migrate deploy command in docker file, its not creating table in postgres- Google Cloud
  • a

    Antoin Campbell

    06/27/2021, 4:23 PM
    anyone here use prisma with google cloud run? I’m setting up my dockerfile and trying to run
    prisma migrate deploy
    during the build step and im getting this error:
    Copy code
    [builder 7/9] RUN npx prisma migrate deploy:
    #11 1.611 Prisma schema loaded from prisma/schema.prisma
    #11 1.644 Error: Get config: Schema Parsing P1012
    #11 1.644
    #11 1.644 error: Environment variable not found: DATABASE_URL.
    #11 1.644   -->  schema.prisma:6
    #11 1.644    |
    #11 1.644  5 |   provider = "postgresql"
    #11 1.644  6 |   url      = env("DATABASE_URL")
    #11 1.644    |
    #11 1.644
    #11 1.644 Validation Error Count: 1
    #11 1.644
    I have the
    DATABASE_URL
    environment variable set inside of the cloud run service environment but I have a feeling this is probably not helpful during the build step as I believe that is a runtime concern. anyone have any thoughts or suggestions on this flow/problem?
    r
    • 2
    • 8
  • s

    Sasi

    06/27/2021, 5:06 PM
    Copy code
    Running generate... (Use --skip-generate to skip the generators)
    Error: Schema parsing
    error: Found argument '--enable-experimental' which wasn't expected, or isn't valid in this context
            Did you mean --enable-playground?
    
    USAGE:
        query-engine-debian-openssl-1.1.x --enable-playground
    r
    j
    • 3
    • 13
  • s

    Sasi

    06/27/2021, 5:06 PM
    getting this error on running
    prisma migrate dev
  • s

    Sasi

    06/27/2021, 5:08 PM
    any idea?
  • t

    Temm

    06/27/2021, 9:06 PM
    is it possible to aggregate sum by relation in Prisma? so i have types [Order; Vendor] Relation is many Order per Vendor so Order has the ID of Vendor I want to make a query to sum the price of all orders of each vendor, so i get a number for each vendor that is the total price of their orders Is that possible without looping over vendors?
    r
    • 2
    • 1
  • t

    Temm

    06/28/2021, 6:47 AM
    Why does groupBy not return a PrismaPromise, making it impossible to use it in $transaction as it is missing the { [symbol Prisma]: true } property that identifies it as a prisma awaitable?
    r
    • 2
    • 3
  • m

    Martí Crespí

    06/28/2021, 6:50 AM
    Hi guys! I have a problem. When I run
    prisma introspect
    works as expected, generating my models and all its relations. Then, I run
    prisma generate
    and works well too. But when I try to debug my app it throws an exception telling me that my database is not running..
    Copy code
    Can't reach database server at `localhost`:`5432`
    
    Please make sure your database server is running at `localhost`:`5432`.
        at LineStream.<anonymous> (d:\Prisma2-test\node_modules\@prisma\client\runtime\index.js:27666:31)
        at LineStream.emit (events.js:200:13)
        at addChunk (_stream_readable.js:294:12)
        at readableAddChunk (_stream_readable.js:275:11)
        at LineStream.Readable.push (_stream_readable.js:210:10)
        at LineStream.Transform.push (_stream_transform.js:150:32)
        at LineStream._pushBuffer (d:\Prisma2-test\node_modules\@prisma\client\runtime\index.js:3829:19)
        at LineStream._transform (d:\Prisma2-test\node_modules\@prisma\client\runtime\index.js:3823:10)
        at LineStream.Transform._read (_stream_transform.js:189:10)
        at LineStream.Transform._write (_stream_transform.js:177:12) {clientVersion: '2.25.0', errorCode: undefined, stack: 'Error: Can't reach database server at `localh…ransform._write (_stream_transform.js:177:12)', message: 'Can't reach database server at `localhost`:`…ase server is running at `localhost`:`5432`.'
    Someone knows what could be happening?
    r
    • 2
    • 4
  • e

    Eslam Genedy

    06/28/2021, 8:42 AM
    Hello everyone, Is prisma day meeting recorded?
    m
    • 2
    • 3
  • j

    jasci

    06/28/2021, 9:35 AM
    Hello everybody, wanted to ask if it’s the proper way to get the relation fields of
    someModelName2
    ?
    Copy code
    prisma.someModelName0.findUnique(...).someModelName1().someModelName2({
      include: {
        someModelName3: {
          select: {
            someFieldName: true
          }
        }
      }
    })
    I didn’t found any info about this in the Fluent Api docs. I mean the usage of
    select
    and
    include
    here. It seems that it’s working, but wanted to ask anyway. Thank you.
    r
    • 2
    • 5
  • j

    jasci

    06/28/2021, 10:06 AM
    Hello again, quick question, how can I get the variation of typings for a particular model? Lets say I’ve got a
    User
    model with a relation field
    posts
    When I annotate some variable as User type it doesn’t expect to include posts, cause it’s a relation. How can I specify that it’s a User type that includes posts. Or maybe I can annotate even more like it’s a User type with only name and posts (as if I used include posts and select name) I see that when I use
    select
    or
    include
    it properly resolves types. How can I manually do it ?
    r
    • 2
    • 1
  • i

    Ighor Martins

    06/28/2021, 10:21 AM
    Hey guys. I’m working on a project where I’m rewriting an existing website that has 7M monthly views (10m p/ day). I’m used to work with hasura, but this project needs a very custom backend, and each user visit needs to go to the database. So I need to think a bit about performance. When you query hasura through GraphQL, it normally compiles the entire query into a single SQL query to the database, and that’s how it gets good performance. There is a lot of info on how prisma is slow on the internet, but I know a lot of them are from prisma 1. How different is prisma 2 performance wise? How does it compare with Hasura now? Knowing that I’ll have to write the entire graphql server myself, it means that simply writing resolver for each entity will end up in a lot of queries to the database for just a single graphql query with nested resource, right?
    n
    • 2
    • 3
  • u

    user

    06/28/2021, 10:25 AM
    Prisma Day 2021

    https://www.youtube.com/watch?v=Yw8AWFZlXXE▾

    Prisma Day is two day event of talks and workshops by members of the Prisma community, on modern application development and databases. Prisma Day 2021 is taking place June 29-30th and is entirely online. Learn more about Prisma: ◭ Website: https://www.prisma.io​​​ ◭ Docs: https://www.prisma.io/docs​​​ ◭ Quickstart: https://www.prisma.io/docs/getting-started/quickstart-typescript
  • b

    Ba Thien Tran

    06/28/2021, 10:31 AM
    Hey everyone! I am running a raw sql query to insert sth and it returns 400. How can I view the error messages / logs?
    r
    • 2
    • 14
  • a

    Adam

    06/28/2021, 11:59 AM
    Is there a way to increment a number field in prisma without retrieving the existing object?
    r
    • 2
    • 2
  • a

    aqib

    06/28/2021, 1:11 PM
    Hey everyone! I am using the
    prsima version 1
    and implementing the subscription, when running the subscription in playground and executing a mutation in another tab in the playground I see that the subscription is not responding to the changes in the db it is just spinning. Do I need to use pubSub in the mutation resolvers.
  • j

    Julien Goux

    06/28/2021, 3:10 PM
    Hello all 👋 How are you defining fake data / seeds / fixtures in your tests involving Prisma? I’m surprised prisma-test-utils which seems very useful is unmaintained. Is there anything replacing it?
    r
    j
    • 3
    • 6
  • t

    Tim Mensch

    06/28/2021, 4:20 PM
    Hello all--I just came across something a bit annoying. Looks like Prisma 2 is trying to be "smart" by checking constraints that are implied by its known foreign key settings. I'm simply doing:
    Copy code
    await prisma.myTable.deleteMany();
    ...and I'm getting an error from Prisma. When I replace it with
    Copy code
    await prisma.$executeRaw(`DELETE FROM "myTable";`);
    It works fine. I'm using PostgreSQL. I really want to rely on Postgres to enforce any constraints, if only because, well, Postgres is going to do the foreign key constraint check anyway, and therefore whatever query Prisma is performing to verify the constraint is 100% wasted time. This particular situation is easily worked around (and it's mostly irrelevant anyway, since it's part of the debug DB seed code); what worries me is any more "trying to be smart" queries Prisma might be doing every time any change is made to the data that mean we get 2-3x as many DB calls as actually required for an operation. (As to why I was getting a bogus error: I'm using the "hacked"
    @view
    approach to expose a
    MATERIALIZED VIEW
    to Prisma. I don't actually care that the mapping isn't perfect, so it's not really relevant, unless somehow the
    @view
    approach is causing the extra query above.)
    r
    j
    • 3
    • 10
  • p

    Peter Kellner

    06/28/2021, 4:21 PM
    I've been wrestling (and loosing) with the GraphQL-NextJS example trying to add the "Profile" table and type. Specifically, after I think I've updated all the code correctly, the code in the mutation fails and I get the error:
    "Cannot read property 'profile' of undefined",
    I notice that the profile adding instructions are the same for all the other examples (or at least for the Profile add). My question is: "Does anyone of completed code that works for adding a Profile, and specifically the first mutation in the example? After debugging some, the code in the mutation that seems to be problematic is here in the line
    context.prisma.profile.create
    Copy code
    t.field("addProfileForUser", {
      type: "Profile",
      args: {
        email: stringArg(),
        bio: stringArg(),
      },
      resolve: async (_, args, context) => {
        return context.prisma.profile.create({
          data: {
            bio: args.bio,
            user: {
              connect: {
                email: args.email || undefined,
              },
            },
          },
        });
      },
    Copy code
    mutation {
      addProfileForUser(
        userUniqueInput: {
          email: "<mailto:mahmoud@prisma.io|mahmoud@prisma.io>"
        }
        bio: "I like turtles"
      ) {
        id
        bio
        user {
          id
          name
        }
      }
    }
    r
    • 2
    • 3
  • p

    prisma chobo

    06/28/2021, 4:27 PM
    How do I create many nested records? like on insert cascade. For example, something like this….
    Copy code
    user = await prisma.user.create({
          data: {
            email,
            password: hashedPassword,
            phoneNumber,
            accounts: {
              create: [
                {
                  type,
                  profile: {
                    create: [
                      {
                        email,
                        firstName,
                        lastName,
                        phoneNumber,
                      }
                    ]
                  }
                },
              ],
            },
          },
        });
  • p

    Pierre Ortega

    06/28/2021, 4:28 PM
    @prisma chobo what is the problem with that?
  • p

    prisma chobo

    06/28/2021, 4:28 PM
    it does not show me the type of profile
  • p

    prisma chobo

    06/28/2021, 4:28 PM
    everything is any type inside profile
    r
    • 2
    • 4
  • s

    Spencer Curry

    06/28/2021, 6:32 PM
    hey yall! where can i read about using indexes in conjunction with Prisma?  Is it possible to optimize deeply nested Prisma queries using indexes? I'm using MySQL btw
    👋🏾 1
    👋 1
    r
    j
    • 3
    • 4
  • p

    Peter Kellner

    06/28/2021, 6:44 PM
    Is there are repo with a up to date version of NextJS, Prisma and Apollo (client and server). The one there now uses HOC’s and getInitialProps which means to me it’s very very old. https://dev.to/prisma/complete-introduction-to-fullstack-type-safe-graphql-feat-next-js-nexus-prisma-c5 and https://github.com/prisma/prisma-examples/tree/latest/typescript/graphql-nextjs I’m trying to keep a good attitude about Prisma but my newby experience is not going well.
    r
    p
    • 3
    • 5
  • m

    Michael Grigoryan

    06/28/2021, 7:05 PM
    Hello everyone, hope you're doing well. I was wondering if there's the possibility to do something like this in Prisma... This is the
    schema.prisma
    that I want to achieve
    Copy code
    const uuid = require("uuid");
    
    model User {
      id      Int      @default(autoincrement()) @id
      email   String   @unique
      name    String?
      posts   Post[]
      profile Profile?
    }
    ✔️ 1
    s
    • 2
    • 7
  • m

    Michael Grigoryan

    06/28/2021, 7:05 PM
    Like to generate IDs automatically but with a package from NPM
  • u

    user

    06/29/2021, 7:08 AM
    What's new in Prisma (v2.26.0)

    https://www.youtube.com/watch?v=i8TqB5ofVaM▾

    Daniel and Ryan from the Prisma team discuss news in the Prisma ecosystem. Tune in to learn about new releases, planned features, and other interesting bits from the Prisma world. Learn more about Prisma: ◭ Website: https://www.prisma.io​​​​ ◭ Docs: https://www.prisma.io/docs​​​​ ◭ Getting started: https://www.prisma.io/docs/getting-st...
  • j

    Jemin Kothari

    06/29/2021, 7:56 AM
    Hello everyone, Can anyone please check this issue https://github.com/prisma/prisma/issues/7906 ?
  • e

    Edmir Suljic

    06/29/2021, 9:45 AM
    Hey guys, what is the prisma.exists. equivalent in prisma 2?
    r
    • 2
    • 20
1...450451452...637Latest