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

    Mike Willbanks

    02/01/2022, 3:56 PM
    NIce! Now all we need is a DynamoDB connector 😉
    prisma cool 5
  • s

    Sébastien ELET

    02/01/2022, 4:03 PM
    🙏 for native types, view support and prisma schema split
  • u

    user

    02/01/2022, 4:23 PM
    GraphQL Berlin Meetup #25 + a raffle!

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

    Tune in for the 25th edition of GraphQL Berlin Meetup! 🤗 Connect with the GraphQL enthusiasts worldwide, get inspired by the talks, join the Q&A session and win prizes in the raffle. 🎁 🌍 We have three amazing speakers presenting at this event: ◭ Jamie Barton (@notrab) - "Federating the Content Layer with GraphCMS", ◭ Jason Kuhrt (@JasonKuhrt) - on Nexus, ◭ Matteo Collina (@matteocollina) - "GraphQL caching demystified". More details to follow!
  • l

    Leonard

    02/01/2022, 4:55 PM
    hey
  • s

    Sumit

    02/01/2022, 6:02 PM
    Prisma have Google app engine deployment doc ?
  • s

    Sumit

    02/01/2022, 6:03 PM
    Any one please tell what is the procedure to deploy prisma to app engine ?
  • n

    n

    02/01/2022, 7:08 PM
    does anyone have a pagination example with nestjs + graphql that also returns count
    a
    • 2
    • 8
  • l

    Levi Mason

    02/01/2022, 11:45 PM
    Hello all, I'm currently building a task app using Next.js, Prisma, Chakra, and (unless there's a better option..?) NextAuth.js. This is my first time using Prisma and I was wondering if anyone who's got a little more experience would be willing to look over my schema? This is also my first time trying to setup Authentication and Authorization so any help would be appreciated.
    e
    • 2
    • 4
  • f

    femzy

    02/02/2022, 1:56 AM
    Hello, I'm a first time prisma user. I am currently building a shopping cart application using nodejs, express and prisma. Looks really exciting
    🙌🏿 1
    🙌 3
    prisma rainbow 4
  • p

    Paul ANDRIANTEFY

    02/02/2022, 8:54 AM
    Hello! how to order by average pls?
    n
    • 2
    • 3
  • m

    Marvin

    02/02/2022, 1:41 PM
    Hey everyone! AFAIK it's possible to share the generated Prisma types from the backend with the frontend, but I'm not 100% sure what it would look like in a monorepo with following structure: packages/ • backend/ • frontend/ Would I just create a separate package inside packages/ and use a custom build output .e.g '../models/node-modules/.prisma/client'?
    s
    a
    n
    • 4
    • 13
  • a

    Adam Boulila

    02/02/2022, 2:07 PM
    Hello Everybody, I am using Data Proxy with Prisma. up until yesterday everything works fine but today, all requests to get data through the data proxy take around 30 seconds running then timeout with
    code: 'P5006' Unknown Server Error
    , I can make requests directly to the DB using Prisma and it works, just the data Proxy that does not I have even created a new project and i still get the same problem with data proxy
    k
    n
    • 3
    • 3
  • t

    Topi Pihko

    02/02/2022, 2:32 PM
    Good morning/afternoon/evening! I'm trying to figure out how to subquery data with Prisma. Eg. I would like to get Resources of certain Factory, but there is either Cell or Department -table between. I guess it's doable with query and without filtering, but what's the magic keyword?
    Copy code
    this.prisma.resource.findMany({
        include: {
          department: true,
          cell: true,
        },
      })
    ).filter(
      (resource) =>
        resource.department.factoryId == factoryId || resource.cell.factoryId == factoryId,
    );
    a
    a
    • 3
    • 11
  • g

    Glaucia Lemos

    02/02/2022, 2:56 PM
    hi, everyone!
    🇧🇷 1
    👋 1
    n
    • 2
    • 1
  • p

    pzaenger

    02/02/2022, 4:43 PM
    We have a server template adding Prisma to the server. It works fine so far. We now have another server extending this template without the need of models (just raw queries). While generating the Prisma client, it is complaining about not having at least one model. However, we would like to use Prisma here as well. Is there any way to generate the client without models? We don't want to add an exception (like using pg). Thanks :)
    n
    • 2
    • 2
  • m

    Mike Willbanks

    02/02/2022, 6:19 PM
    Are binary targets still required for aws lambda?
    • 1
    • 3
  • m

    matic

    02/02/2022, 7:22 PM
    Hi all 👋, Not sure how common this is but we are running a server on Render and use Prisma connected to a Postgres hosted database and we are hitting lots of “Error: Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 9)“. We are running a single instance on Render and Starter plan and our service uses a shared
    PrismaClient
    instance that we export as
    client
    variable from a shared file. Any tips?
    a
    i
    • 3
    • 4
  • j

    Jon

    02/02/2022, 7:23 PM
    Quick question -- if I want to get all of the upvotes and downvotes from
    Users
    per
    Post
    OR get all of the upvotes and downvotes per
    User
    how would I construct the schema? I've tried a bunch of permutations but can't figure out how to do the relations:
    Copy code
    model Post {
      id         Int @id @default(autoincrement())
      upvotes    User[]
      downvotes  User[]
    }
    
    model User {
      id Int @id @default(autoincrement())
      upvotes Post[]
      downvotes Post[]
    }
    m
    • 2
    • 2
  • f

    femzy

    02/02/2022, 7:44 PM
    I am building a shopping cart app using nodejs, mysql and prisma My model
    Copy code
    model User {
      id          Int @id @default(autoincrement())
      name        String
      email       String @unique
      password    String
      createdAt   DateTime @default(now())
      products    Cart[]
    
      @@map("users")
    }
    
    model Product {
      id          Int @id @default(autoincrement())
      name        String @unique
      description String
      price       Int
      stock       Int
      sku         String
      createdAt   DateTime @default(now())
      Category    Category? @relation(fields: [categoryId], references: [id])
      categoryId  Int
      users  Cart[]
    
      @@map("products")
    }
    
    model Category {
      id          Int @id @default(autoincrement())
      name        String @unique
      products    Product[]
      createdAt   DateTime @default(now())
    
      @@map("categories")
    }
    
    model Cart {
      id  Int   @id @default(autoincrement())
      user User @relation(fields: [userId], references: [id])
      userId  Int
      product Product @relation(fields: [productId], references: [id])
      productId Int
      quantity  Int
    }
    I made the Cart table a join table due to the User and Product having a Many-to-Many relationship My Routes
    Copy code
    router.get("/", async (req, res) => {
      try {
        const cart = await prisma.cart.findMany({
          include: { product: true },
        });
        res.status(200).json(cart);
      } catch (error) {
        res.status(500).json(error);
      }
    });
    
    // Fetch a user's cart
    router.get("/:userId", async (req, res) => {
      try {
        const cart = await prisma.cart.findOne({
          where: { userId: req.params.userId },
          include: { product: true },
        });
        res.status(200).json(cart);
      } catch (error) {
        res.status(500).json(error);
      }
    });
    
    <http://router.post|router.post>("/", async (req, res) => {
      try {
        const cart = await prisma.cart.create({
          data: req.body,
        });
        res.status(200).json(cart);
      } catch (error) {
        res.status(500).json(error);
      }
    });
    
    module.exports = router;
    My route to fetch a user's cart is not working, please what could be the problem and any advice to make the app better would be appreciated
    m
    • 2
    • 2
  • c

    Chris

    02/02/2022, 8:02 PM
    Hi all 👋 Schema:
    Copy code
    model Series {
      id          Int     @id @default(autoincrement())
      name        String
      deck        String?
      description String?
      year        String
      publisher   String
      count       Int
      externalId  String  @unique
      issues      Issue[]
    }
    
    model Issue {
      id         Int    @id @default(autoincrement())
      series     Series @relation(fields: [seriesId], references: [id])
      seriesId   Int
      name       String
      externalId String @unique
    }
    Code running within a BullMQ worker:
    Copy code
    const operations = issues.map(issue => {
          const { id: issueExternalId, name } = issue
    
          return prisma.series.update({
            where: {
              id: seriesId
            },
            data: {
              issues: {
                create: {
                  name,
                  externalId: issueExternalId
                }
              }
            }
          })
        })
    
        const [_, total] = await prisma.$transaction(operations)
    For some reason the transaction just appears to hang. I've enabled logging/debug and it's like it doesn't even attempt to run the query. Been banging my head against it for a few hours. Any ideas?
  • l

    Luan Rodrigues

    02/02/2022, 8:46 PM
    Hello everyone, is there any workaround for aliases using prisma queries? Looping all the keys to swap some values when you have a nested query is painful. Thanks! 🙂
  • t

    Tyler Bell

    02/02/2022, 11:43 PM
    Is the enterprise program still available? I’ve filled out the form twice over the past few months and haven’t received any response 🙁 Would love to learn more about it for my company 😄
    v
    • 2
    • 3
  • c

    Cory McAboy

    02/03/2022, 4:38 AM
    Can anyone recommend a good query performance monitoring tool for a prisma based BE?
  • c

    Cory McAboy

    02/03/2022, 4:39 AM
    Was looking to use new relic, but seems like that is a no go since prisma does not use the pg driver.
  • m

    Mischa

    02/03/2022, 11:02 AM
    Trying to use an ISO8601 string or a Date object in a raw query but getting the error
    Copy code
    Raw query failed. Code: `42P18`. Message: `db error: ERROR: could not determine data type of parameter $1`
  • u

    user

    02/03/2022, 12:30 PM
    Improving Prisma Migrate DX with two new commands Prisma Migrate is a database schema migration tool that simplifies evolving the database schema productively and predictably. We are launching two new low-level Preview Migrate commands to improve the developer experience when troubleshooting schema migrations. Try them out and share your feedback.
    c
    • 1
    • 1
  • i

    Ibad Shaikh

    02/03/2022, 2:22 PM
    Hi Prisma Family.👋 • I have added a model special_password and the migration was created successfully on the local database. • The migration file also generated and the migration record is also created in the database and the applied field is also set as 1 i.e true. • When I try to use findFirst() on this model, it throws me this error : `"\nInvalid 
    prisma.special_password.findFirst()
     invocation:\n\n\n  Failed to validate the query: 
    Field does not exist on enclosing type.
     at `Query.findFirstspecial_password`"` • Even the prisma studio is showing the record of this table. I have also updated prisma from "3.2.1" to "3.9.1" but it still fails. I also cleaned my npm cache but still the same error. Also used prisma db push and prisma db pull commands but its says The database is already synced. Prisma Query:
    Copy code
    await prisma.special_password.findFirst({
        where: {
          password: req.body.password,
        },
      })
    • And If I try to call .delete( ) method it throws: `nUnknown arg 
    password
     in where.password for type special_passwordWhereUniqueInput. Available args:\n\ntype special_passwordWhereUniqueInput {\n  id?: Int\n}\n\n\n    at Object.validate` It means the query is not considering password as the field of this model. But inside vscode, the password field is provided as a hint which means that this field is supported but when the query is ran, it throws error.
    • 1
    • 1
  • j

    Jonathan Marbutt

    02/03/2022, 3:18 PM
    I have a design question and migration question. In other ORMs I used some basic table inheritance with most tables inheriting from a base class called
    EntityCommon
    where I would keep some common fields like
    UpdatedDate
    Name
    and a few others. This allowed me to do global searching and other things in the app. So my question is how to best accomplish this in prisma, I know I will just have to manually create the
    model
    in the schema and link every table to it as a 1:1 relationship. Where I start to run in my question, is generating the data in the
    EntityCommon
    table, other ORMs handle this pretty well, but I would prefer to do it at the database level anyways. Would I be better off creating a trigger for each table to maintain the
    EntityCommon
    and should I keep those triggers in something for the migrations? Or should I rely on the
    $on
    events in prisma?
  • m

    Murty Munukutla Satyanarayana

    02/03/2022, 3:55 PM
    Team, We are using full text search functionality of Prisma with Postgresql. If I have a table like below CREATE TABLE Configs ( id serial4 NOT NULL primary key, config text NULL ); It has a text index like below. CREATE INDEX ix1 ON Configs USING GIN (to_tsvector(‘simple’::regconfig, config)); And when using GraphQL query on this table below query { findManyConfigs(take:100, where: { config: { search: “xxxxx” } }) { id } } It is executing query something like below on database. SELECT “schemaname”.“Configs”.“id”, “schemaname”.“Configs”.“config” FROM “schemaname”.“Configs” WHERE to_tsvector(concat_ws(' ’, “schemaname”.“Configs”.“config”)) @@ to_tsquery(‘xxxxx’) ORDER BY “schemaname”.“Configs”.“id” ASC LIMIT 100 OFFSET 0; But it is not able to use the index that was created on table. And we could not create a function based index to_tsvector(concat_ws(' ’, “schemaname”.“Configs”.“config”)) because the functions are not IMMUTABLE. Is there a way that we can make prisma generated queries to use the text based index on the table? Or suggestions on what index need to be created to have optimized execution of prisma generated query. Thank you for the help.
    n
    • 2
    • 3
  • n

    Nick B

    02/03/2022, 6:47 PM
    Not seasoned w/ DBs here - Can someone explain to me why it's so cumbersome to add a column to an existing database without data loss? I'm used to a phpmyadmin environment and I'm just trying to understand.
1...540541542...637Latest