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

    Marco Moi

    09/27/2021, 11:52 AM
    Hi guys, I am trying to deploy a Next.js app to Aws Amplify. I am using Prisma and graphql into the api routes of next.js. Every time Prisma client is used on an api route, I get 503 from cloud front. On vercel, I don't have any of these problems. There is any configuration that I am missing for make working Prisma client on AWS Amplify hosting?
    r
    • 2
    • 13
  • m

    Matija Sosic

    09/27/2021, 2:34 PM
    Hi! I have
    List
    which has one more
    Card
    s (imagine Trello). If for a particular card I want to change ownership (make it owned by another list), how I can do that?
    Copy code
    export const updateCard = async ({ cardId, data }, context) => {
      return context.entities.Card.update({
        where: { id: cardId },
        data: {
          // What should I write below? A failed attempt:
          list: { connect: { id: data.listId } }
        }
      })
    }
    r
    • 2
    • 15
  • j

    Justin Ellingwood

    09/27/2021, 3:10 PM
    Just put up a new article on Prisma's Data Guide. An overview of some common infrastructure patterns for RDBMSs https://www.prisma.io/dataguide/types/relational/infrastructure-architecture
    🎉 1
    🦜 2
    🌟 1
  • b

    Bamada

    09/27/2021, 4:00 PM
    Hi, I want to initialise a migration on an existing DB using this command
    npx prisma migrate dev --create-only
    but I still get a prompt that request me to reset my database what i want to avoid. Is it possible to do that without reset my db?
    Copy code
    /app $ npx prisma migrate dev --create-only
    Environment variables loaded from .env
    Prisma schema loaded from prisma/schema.prisma
    Datasource "db": PostgreSQL database "mercure", schema "public" at "db:5432"
    
    ? Drift detected: Your database schema is not in sync with your migration history.
    
    The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.
    
    It should be understood as the set of changes to get from the expected schema to the actual schema.
    
    [+] Added tables
      - mercure_configs
      - mercure_responses
    
    [*] Changed the `mercure_configs` table
      [+] Added unique index on columns (po)
    
    
    We need to reset the PostgreSQL database "mercure" at "db:5432".
    Do you want to continue? All data will be lost. › (y/N)
    r
    • 2
    • 2
  • i

    Ibad Shaikh

    09/27/2021, 7:45 PM
    Hi 👋 I want to get the count using relational query :
    _await prisma.model.count_({
          
    _select_:_ _{
            
    _id_: _true_,
            
    _user_:_ _{
              
    _select_:_ _{
                
    _username_: _true_,
    _          _},
    _        _},
            
    _category_:_ _{
              
    _select_:_ _{
                
    _name_: _true_,
    _          _},
    _        _},
    _      _})
    As we already knew that currently its not possible to use select and include at the same time. So I came through another approach without using the include keyword and just directly create a nested object on the field you had a relation with like in my case its user and category. The above query is working fine on .findMany() but it fails on .count(). it throws the error above : _Unknown field
    user
    for select statement on model PostCountAggregateOutputType. Available options are listed in green. Did you mean
    user_id
    ?_
    r
    • 2
    • 1
  • m

    Mischa

    09/28/2021, 6:46 AM
    has anyone tried using Prisma or Prisma-AppSync with AWS Amplify? wondering if it's possible. that'd be a dream matchup.
  • a

    Alexei Snisarenko

    09/28/2021, 11:40 AM
    greeting community. I have two instances of PrismaClient in my nodejs application (application lives in ECS contain in AWS if that matters). One client connects to reader db instance (postgres) and other connects to writer db instance. all of a sudden I get
    "Timed out fetching a new connection from the connection pool"
    which now does not disappear. there is no activity currently in the app but when try to do query get this error. Did anybody face such a problem and if yes what would be possible reason of the problem do get addressed? Any advice would be highly appreciated
    r
    j
    • 3
    • 12
  • j

    Jonas Rothmann

    09/28/2021, 12:24 PM
    If I have a self-relation on my user model which is one-to-many, how do I best loop through that entire tree? It feels like it's bad performance to run a query for every single customer and go through one-by-one
    r
    • 2
    • 7
  • j

    jt

    09/28/2021, 4:21 PM
    I built an app last year with Prisma V1. I want to create a progress bar and I was wondering if there's a way to return data during a mutation without interrupting it so that I can create/update a progress bar on the client side? I've got a mutation in my resolvers called importOrders, which runs another mutation named createOrder that creates orders based on data from a CSV file. So, for instance, I may be running createOrder 200 times within the importOrders mutation and I want to be able to show the client how many times the createOrder mutation finished successfully. Thanks.
  • u

    user

    09/28/2021, 5:20 PM
    Prisma Chats with Bram Borggreve - How to use Prisma in production

    https://www.youtube.com/watch?v=CUEUXcSZaf4â–¾

    In this video, Daniel from the Prisma team interviews Bram Borggreve. Bram is a software engineer, educator, and Prisma ambassador who is passionate about improving developer productivity and making programming more accessible and easier for existing and new developers. Bram has been using Prisma for 2 years. He currently works at the Kin Foundation as Sr. Technical Advisor and he is the founder of a foundation called BeeSoft Labs which aims to educate underprivileged people in Colombia, and hopefully in the future extend beyond that. They discuss how Bram uses Prisma in production projects, the value Prisma provides when embracing rapid prototyping, Bram's technology stack, developer tooling, and how Prisma can be used as an educational tool. Timestamps: 00:30 Bram Introduction 01:44 How Bram uses Prisma 02:49 Bram's technology stack 6:55 Rapid development & tools used 8:17 Importance of conventions in teams 10:24 Why Prisma is handy 12:01 Approach for building the nxpm/stack 14:21 Usage of Prisma in different projects 15:36 What is a "module" and how to streamline a process 21:04 Most awaited Prisma feature 25:37 Deployment paradigms 30:08 How to use Prisma as an educational tool 32:04 How to think of the Prisma schema 36:50 Prisma cloud platform Bram Borggreve contact details: ✨ Twitter: https://twitter.com/beeman_nl ✨ YouTube: https://www.youtube.com/c/beeman-dev ------------------------ 📚 Resources: ✅ Subscribe to Prisma: https://www.youtube.com/channel/UCptAHlN1gdwD89tFM3ENb6w?sub_confirmation=1 ✅ Get help from the Prisma Community: https://slack.prisma.io/ ✅ Learn more about Prisma: https://www.prisma.io ------------------------ 💬 Connect with Prisma: Twitter: https://twitter.com/prisma Instagram: https://www.instagram.com/prisma.io/ TikTok: https://www.tiktok.com/@prismadata Facebook: https://www.facebook.com/prisma.io LinkedIn: https://www.linkedin.com/company/prisma-io ------------------------ Prisma sponsors human-reviewed, professional closed captions for ANY video valuable to our community (for example, about: Node.js, TypeScript & Type Safety, Prisma, databases, etc). Get your FREE captions here: https://pris.ly/closedcaptions
  • g

    garyditsch

    09/28/2021, 6:03 PM
    I'm currently building an app with: Nextjs, react-query, Prisma, postgres .. I'm currently using DigitalOcean to host the db, things are working well, but after a little development I start to get 500 errors on the server, if I stop and restart the development server things work fine. My assumption is that I'm running out of connections on the db. I did see this video by Daniel with a possible solution:

    https://www.youtube.com/watch?v=tsOHw2T1HvIâ–¾

    . -- My question though, how can I test that this is actually the problem prior to setting up PgBouncer?
  • j

    Joseph

    09/29/2021, 12:40 AM
    Hello Geeks, Is there a way to exclude columns (like passwords & other private tokens) from prisma query responses. Probably a shorter way instead of implicit select
    r
    • 2
    • 1
  • m

    Magne Skutle

    09/29/2021, 7:26 AM
    Hey everyone! Not sure if this is the right place to ask this question, but I'm struggling a bit with prisma and integration testing. I'd like to specify a different DATABASE_URL when running my tests in Jest, such that I don't mess up my dev database. Is there a way to configure this? I configure different env variables for testing in the "setupFilesAfterEnv" jest config option, such as log level, api host etc. and they're all picked up by Jest. However, specifying a different DATABASE_URL doesn't make prisma pick it up. It still loads the DATABASE_URL value from the .env file (which points to my dev db).
    r
    • 2
    • 3
  • u

    user

    09/29/2021, 7:27 AM
    Overview of the part-2 Branch

    https://www.youtube.com/watch?v=-x7yENX3s9Mâ–¾

    In this video, we'll go over what you'll learn in the second part of the course. Timestamps: 00:00 - 00:54 What you'll learn in Part 2 of the course 00:55 - 01:30 Cloning the branch and going over the dependencies 01:30 - 3:59 Including a database URL + Seeding the database 4:00 - Going over other files and dependencies • GitHub repo: https://github.com/m-abdelwahab/awesome-links • Part 2 blog post: https://prisma.io/blog/fullstack-nextjs-graphql-prisma-2-fwpc6ds155 • Part 1 blog post: https://prisma.io/blog/fullstack-nextjs-graphql-prisma-oklidw1rhw 👉 Next video: REST vs. GraphQL -

    https://www.youtube.com/watch?v=f1KxJi-2PFo&list=PLn2e1F9Rfr6k6MwzS-p9FGK1NDBxxwLPk&index=11&pp=sAQBâ–¾

    👉 Check out the full playlist: https://www.youtube.com/playlist?list=PLn2e1F9Rfr6k6MwzS-p9FGK1NDBxxwLPk
  • j

    Jaroslav Malek

    09/29/2021, 3:03 PM
    Hey guys, I am wondering if you also experienced this issue. When calling a nested create and some of the keys end with
    Id
    even tho it’s not meant to be a foreign key, the mutation errors. Example:
    Copy code
    prisma.business.create({
        data: {
          name: data.name,
          // This is just a string and it is not supposed to be a FK, but Prisma thinks so
          taxId: data.taxIdentifier,
          address: {
            create: {...},
          },
          clientOf: {
            connect: {
              id: businessId,
            },
          },
        },
      })
    The way to fix this is to rename it from
    taxId
    to
    taxIdentifier
    for example. I was trying to find an issue in Github, but there is just so many issues and it’s hard to find it.
    r
    • 2
    • 8
  • h

    Harsha MV

    09/29/2021, 3:36 PM
    Am not able to figure how to solve this issue
    Copy code
    rismaClientKnownRequestError: 
    Invalid `prisma.projectType.findMany()` invocation:
    
    
      Timed out fetching a new connection from the connection pool. (More info: <http://pris.ly/d/connection-pool>, Current connection limit: 17)
        at cb (/Users/harshamv/Sites/nftvoltclub/node_modules/@prisma/client/runtime/index.js:36952:17)
        at async getServerSideProps (webpack-internal:///./pages/list-project.js:27:24)
        at async Object.renderToHTML (/Users/harshamv/Sites/nftvoltclub/node_modules/next/dist/server/render.js:473:24)
        at async doRender (/Users/harshamv/Sites/nftvoltclub/node_modules/next/dist/server/next-server.js:1127:38)
        at async /Users/harshamv/Sites/nftvoltclub/node_modules/next/dist/server/next-server.js:1221:28
        at async /Users/harshamv/Sites/nftvoltclub/node_modules/next/dist/server/response-cache.js:60:36 {
      code: 'P2024',
      clientVersion: '3.1.1',
      meta: { connection_limit: 17 }
    }
    this is my prisma file:
    Copy code
    import { PrismaClient } from '@prisma/client';
    
    let prisma;
    
    if (process.env.NODE_ENV === 'production') {
        prisma = new PrismaClient();
    } else {
        if (!global.prisma) {
            global.prisma = new PrismaClient();
        }
    
        prisma = global.prisma;
    }
    
    export default prisma;
    r
    • 2
    • 2
  • a

    Anonymous World

    09/29/2021, 5:45 PM
    Nextjs Prisma Vercel how to use migrate command?
    e
    h
    • 3
    • 6
  • o

    Oleg Yarin

    09/29/2021, 6:20 PM
    Hey dear Prisma team, I am currently testing prisma against typeorm with PostgreSQL. I am trying to use nested writes for Prisma. With local DB the query takes around 4s. When I run the same query with remote DB on AWS then it takes around 90s. Would you have any hint on why is it taking so long with remote DB. See more details on stackoverflow. Let me know if you need more details.
    m
    r
    • 3
    • 15
  • n

    Nathaniel Babalola

    09/29/2021, 7:49 PM
    I have been getting this error in Docker from Prisma, and I have no idea why this is happening. Had anyone encountered something like this before?
    • 1
    • 2
  • e

    Elie Steinbock

    09/30/2021, 1:16 AM
    any suggestions for scaling postgres / serverless? we’re using postgres prisma and struggling to write often. writing perhaps 30 new records per second consistently and we added
    pgbouncer=true&pool_timeout=60
    to our database url but we’re still getting timeouts on not enough connections. db has 1gb ram and 1 cpu seeing this error a lot:
    Timed out fetching a new connection from the connection pool. (More info: <http://pris.ly/d/connection-pool>, Current connection limit: 17)
    h
    g
    c
    • 4
    • 5
  • u

    user

    09/30/2021, 11:00 AM
    REST vs GraphQL

    https://www.youtube.com/watch?v=f1KxJi-2PFoâ–¾

    In this video, we'll compare two approaches to building APIs: REST vs. GraphQL. Timestamps: 00:10 - 00:00 How REST APIs work 00:45 - 03:08 Benefits and drawbacks of REST APIs 03:08 - What is GraphQL and how it works This video is part of a course where you learn how to build a fullstack app using Next.js, GraphQL, Prisma, TypeScript, and PostgreSQL 👉 Check out the previous video: Part 2 branch overview -

    https://www.youtube.com/watch?v=-x7yENX3s9M&amp;list=PLn2e1F9Rfr6k6MwzS-p9FGK1NDBxxwLPk&amp;index=10â–¾

    👉 Check out the next video: Next.js GraphQL API using Apollo Server 3 and Prisma Check out the complete playlist: https://www.youtube.com/playlist?list=PLn2e1F9Rfr6k6MwzS-p9FGK1NDBxxwLPk
  • u

    user

    09/30/2021, 11:02 AM
    Using the Prisma Data Proxy with Vercel, Prisma, Next.js, and PostgreSQL

    https://www.youtube.com/watch?v=iyGZ8JFPgoYâ–¾

    In this video, you will learn about how the Early Access version of the Prisma Data Proxy solves database connection management in serverless environments. The Prisma Data Proxy is an external connection pooler that sits between your app and your database so you can reliably use relational databases in serverless environments. In the video, Daniel deploys a Next.js app built with Prisma and PostgreSQL to Vercel and runs a load test to show the database connection limit exhausted. He then imports the project to the Prisma Data Platform and configures the Prisma Data Proxy to eliminate database connection exhaustion. Timestamps: 00:00 - 1:40 The connection pooling problem in serverless environments 1:40 - 5:16 A look at the demo built using Next.js and Prisma 5:16 - 6:16 Deploying the application to Vercel without using the Data Proxy 6:16 - 8:12 Load testing to demonstrate the connection pooling problem using K6 8:12 - 12:20 A look at the Prisma Data Platform and setting up the Data proxy 12:20 - 17:29 Updating the Next.js demo project to use the Data Proxy 17:29 - 18:56 Adding the Data Proxy connection string to the project on Vercel 18:56 - 21:23 Setting to the Vercel build command to run migrations in builds 21:23 - 24:06 Running the load test with the Data Proxy and comparing the results 24:06 - 27:30 Summary
  • n

    Nathaniel Babalola

    09/30/2021, 11:59 AM
    Anyone used Prisma with a supabase PostgreSQL? It hardly connects. If I make 20 DB calls, half will fail , with a
    Can't reach database server at <http://db.xxxxxx.supabase.co:5432|db.xxxxxx.supabase.co:5432>
    . This isn't from my internet as I am making other network requests in my app and they're successful.
  • p

    Phil Bookst

    09/30/2021, 12:22 PM
    Is there any way to extract my prisma queries and transform them into postgres functions?
    r
    • 2
    • 3
  • y

    Yaakov

    09/30/2021, 12:37 PM
    Hello all! I'm strongly considering adopting the Prisma ORM for a very large Node/Express project using SQL Server. While some of the other ORM's e.g. Sequelize, TypeORM, are much more mature, most of the excitement obviously, currently surrounds Prisma. I'm hoping that some of you gurus could advise me if Prisma is well suited for this project or perhaps I should be looking elsewhere. My project will likely need the following list of features. Please advise if they are supported and any known issues/limitations I may expect to run into. Please note that my background is in Laravel/Eloquent, so the terminology is written accordingly: • Eager loading • Composite keys • Polymorphism • Singe table inheritance • Subqueries (w/o resorting to raw expressions) • Common table expressions (CTE) • Pagination • Views • Triggers • Stored procedures • CASE statements • SQL functions (
    MAX
    , 
    UPPER
    , 
    TRIM
    , etc.) Obviously, everything could be accomplished by using raw statements, but I'm looking to stay away from that as much as possible. Any other comments/suggestions are welcome and appreciated! 😄 Thanks in advance!
    r
    • 2
    • 12
  • c

    Conor Wade

    09/30/2021, 12:44 PM
    Hi all, I'm pretty new to Prisma, and I was wondering if it is possible to make a model or fields read-only?
    r
    • 2
    • 2
  • a

    Angelo

    09/30/2021, 1:32 PM
    I have started my Prisma client and now I want to switch the DB that I am connected, I was thinking I could just do
    prisma.$connect("another-db-name")
    but that doesn't seem to work, any ideas? Thanks
    r
    • 2
    • 4
  • v

    Vladi Stevanovic

    09/30/2021, 2:19 PM
    🚀 Today we are launching the Prisma Data Platform survey! Our ecosystem is changing, and the platforms we use are too. With this survey, we aim to capture trends and insights in the Data Platform world, that will inform our roadmap. In particular, we want to understand how we can better solve the challenges organisations face when managing application data. We'll share our learnings with the community and participants also have the chance to win a $50 gift card! 💰 👉 You can learn more about the survey and participate here: pris.ly/data-platform-survey
    💯 3
    prisma green 1
  • t

    Tom

    09/30/2021, 3:08 PM
    Is there a tool that translates raw SQL queries into prisma javascript queries? In particular I’m struggling with sorting nested data. I have got a food with many nutrient values that I want to sort by a specific nutrient value. Not every food has a certain nutrient value. If a food doesn’t have a certain value it should not be included in the result. This is my query:
    Copy code
    SELECT f.id, jsonb_agg(to_jsonb(n)) FROM (
        SELECT f.id AS id, n.amount FROM "Food" AS f
        JOIN "NutrientValue" AS n ON f.id = n."foodId"
        WHERE n."nutrientId" = 1
        ORDER BY n.amount
    ) AS f
    JOIN "NutrientValue" AS n ON f.id = n."foodId"
    GROUP BY f.id, f.amount ORDER BY f.amount;
  • d

    Darryl Morley

    09/30/2021, 3:21 PM
    Hi, any docker geniuses here? I'm having a nightmare trying to connect to my db with Prisma 2 client in docker and looking for some help if possible.
    e
    d
    • 3
    • 9
1...488489490...637Latest