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

    Phil Bookst

    10/06/2021, 10:15 AM
    Hey guys quick question about schema design I have 3 tables, hashtag, image and ImageHashtags (+ 1 profile table) looking like this
    Copy code
    model Hashtag {
      id            String?         @unique
      name          String          @id
      thumbnail     String?
      post_count    Int?
      images        Image[]
      imageHashtags ImageHashtags[]
    
      @@map("hashtag")
    }
    
    model Image {
      id              String           @id
      thumbnail       String
      shortcode       String           @unique
      like_count      Int
      comment_count   Int
      caption         String?          @db.Text 
      hashtag         Hashtag?         @relation(fields: [hashtagName], references: [name])
      hashtagName     String?
      imageHashtags   ImageHashtags[]
      
      @@index([hashtagName])
      @@map("image")
    } 
    
    // Explicit m-n relation good fit for this use case? 
    model ImageHashtags {
      imageId String
      image   Image   @relation(fields: [imageId], references: [id])
      name    String
      hashtag Hashtag @relation(fields: [name], references: [name])
      count   Int  
    
      @@id([imageId, name])
    }
    i'm using the ImageHashtags table to keep a count of how many hashtags were used in an image caption to later aggregate on the hashtag name to find out how often a profile uses a specific hashtag this is working fine but it pollutes my database a lot... right now I have about 10k image rows and 100k rows in the ImageHashtags. is there a way to do this more effectively to reduce row writes?
    • 1
    • 1
  • s

    sagar lama

    10/06/2021, 11:15 AM
    Hi guys, I'm trying to create migration with prisma and I have this issue.
    Copy code
    Error: Unable to require(`/app/node_modules/@prisma/engines/libquery_engine-linux-musl.so.node`)
     Error loading shared library libssl.so.3: No such file or directory (needed by /app/node_modules/@prisma/engines/libquery_engine-linux-musl.so.node)
    ERROR: 1
    I ran the command using
    docker-compose run api npx prisma migrate dev
    My Dockerfile looks like this.
    Copy code
    FROM node:14-alpine as development
    RUN apk add --no-cache git gcc g++ python
    WORKDIR /app
    
    COPY ./ ./
    
    RUN npm ci --ignore-scripts --prefer-offline --silent --no-progress --no-audit
    What am I missing?
    n
    r
    e
    • 4
    • 30
  • s

    sagar lama

    10/06/2021, 11:15 AM
    need help
  • n

    Nathaniel Babalola

    10/06/2021, 11:31 AM
    Has anyone used Prisma with any admin panel or does any admin panel solution support Prisma ?
    r
    n
    • 3
    • 12
  • a

    Amit

    10/06/2021, 12:46 PM
    Hello folks, in Prisma 3.2.0, when I'm trying to update some object's
    Json?
    field (optional JSON), I can't use
    undefined
    because it then just treats it like there's no key, and I can't use
    null
    because then Prisma is angry with me. Can someone please help me update an object in such way? It's not a key within the JSON, but literally I want to update a previously updated JSON (say
    {"a": "b"}
    ) to NULL
    r
    • 2
    • 15
  • e

    EndyKaufman

    10/06/2021, 1:11 PM
    Unable to load Node-API Library
  • e

    EndyKaufman

    10/06/2021, 1:12 PM
    Today error
  • d

    Daniel Uhm

    10/06/2021, 4:21 PM
    Hello. I am always happy with the new features and I am using it well. I have a question. Currently, we are developing Serverless based on AWS Lambda. However, the following or similar warning messages are still occurring. - “Already 10 Prisma Clients are actively running.” Maybe serverless-offline creates a Prisma client again in the process of recompiling this file, but I don’t know the exact cause. The client is allocating as follows.
    import { PrismaClient } from '@prisma/client';
    const prisma = new PrismaClient();
    prisma.$use(async (params, next) => {
    const bypassSoftDeleted: string[] = [];
    if (params.model && !bypassSoftDeleted.includes(params.model)) {
    if (!['create', 'update', 'upsert', 'delete'].includes(params.action)) {
    if (!params.args.where) params.args.where = {};
    if (!params.args.where['deletedAt']) {
    params.args.where['deletedAt'] = null;
    }
    }
    if (['delete', 'deleteMany'].includes(params.action)) {
    if (params.action === 'delete') params.action = 'update';
    if (params.action === 'deleteMany') params.action = 'updateMany';
    if (!params.args.data) params.args.data = {};
    params.args.data['deletedAt'] = new Date();
    }
    }
    return next(params);
    });
    export { prisma };
    The middleware above is a soft delete. Thanks for reading.
    r
    • 2
    • 2
  • a

    Andrew Ross

    10/06/2021, 7:49 PM
    any tips for stitching a remote graphql endpoint with a local prisma/nexus schema? setup: using apollo server micro, nexus, prisma v3.11, nextjs, typescript, codegen goal: trying to stitch the remote endpoint for https://onegraph.com with the prisma generated local schema to make a superschema--integrate services such as GitHub, Google, Facebook, HubSpot, and WordPress into a single graphql endpoint for the apollo client to consume
  • a

    Andrew Ross

    10/06/2021, 7:49 PM
    I watched a video from 2018 using prisma v1 and contentful but that uses graphql-bindings which aren't supported beyond prisma v1 if I'm not mistaken
  • b

    Brendo Souza

    10/06/2021, 11:24 PM
    Hey, guys! Does anyone know if the prism is close to having native support for multi-tenancy apps?
    r
    t
    • 3
    • 2
  • j

    Johannes Bolten

    10/06/2021, 11:41 PM
    Hi, I'm having a weird issue with the upsert function. I'm trying to create or update an entity by it's primary key, and in the update part of the upsert I only update "non special" columns (no constraints on them) Though, I still get an unique constraint error. Which probably means it tries to create a new row instead of updating the currently existing one. Am I doing something wrong here?
    r
    • 2
    • 4
  • y

    YeonHoPark

    10/07/2021, 1:47 AM
    Hi !! Is there an official way to specify the type for the prisma json type ? we are currently using type assertion.
    const _user_ = _await prisma.user.findUnique_({
    _where_:
    {
    _id_:
    1,
    },
    })
    _const userJson_ = _user.json as UserJson_
    type UserJson = {
    name: string
    age: number
    }
    d
    r
    r
    • 4
    • 6
  • j

    Jack Chen

    10/07/2021, 3:25 AM
    Hi , I am new here. Just want to know if any way to convert SQL script to graphql schema?
  • u

    user

    10/07/2021, 12:21 PM
    Setting Up Apollo Client 3 with Nextjs

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

    In this video, you'll learn how to set up Apollo Client in a Next.js app, so you can send GraphQL Queries to a GraphQL API Timestamps: 00:00 - Setting Up Apollo Client 04:00 - Sending a query using the useQuery hook Useful links: • Apollo Client Docs: https://www.apollographql.com/docs/react • Getting Started with Next.js and Apollo Client: https://www.apollographql.com/blog/apollo-client/next-js/next-js-getting-started/ • 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: GraphQL Pagination using Apollo Client and on the Server -

    https://www.youtube.com/watch?v=NaxQXClnYSE&list=PLn2e1F9Rfr6k6MwzS-p9FGK1NDBxxwLPk&index=18&pp=sAQB▾

    👉 Previous video: Creating Object Types Using Nexus -

    https://www.youtube.com/watch?v=NaxQXClnYSE&list=PLn2e1F9Rfr6k6MwzS-p9FGK1NDBxxwLPk&index=16&pp=sAQB▾

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

    Reuben Porter

    10/07/2021, 1:03 PM
    Hi all, I am having an issue with
    prisma.$queryRaw
    and using sql
    ORDER BY
    . I am passing in the order by and direction values as parameters, however the query is not working e.g.
    Copy code
    ORDER BY ${orderBy} ${direction}
    
    should become
    
    ORDER BY name ASC
    Don't suppose anyone has any ideas? Before I've used pg promise
    :raw
    but not sure how to do this the 'prisma way'. Apologies if anything isn't clear.
    r
    • 2
    • 7
  • p

    Peter

    10/07/2021, 2:44 PM
    Hello Everyone:-) Quick question: Can I use Prisma with Azure Database for PostgreSQL server? Because if I formulate my connection string like this on my dev machine
    ""<postgresql://userName@PasswordWithEncodedSpecialCharacters@MyServer.postgres.database.azure.com:5432/DBName?schema=SomeSchema&connect_timeout=100>"
    npx prisma migrate dev --name init
    Fails with
    Error: P1001: Can't reach database server at..
    Maybe to clarify, I basically opened everything up to the outside from within Azure, and using my local SQL Admin Tool to connect to it from the same PC works like a charme..
    ✔️ 1
    • 1
    • 2
  • v

    Vladi Stevanovic

    10/07/2021, 3:10 PM
    🤩 Our DevRel Advocate, Daniel Norman, appeared on the "Azure SQL October Data Exposed Live" hosted by Anna Hoffman from Microsoft! Watch the full live stream to hear about the Prisma Microsoft SQL Server Connector and all the news and updates in the world of data ✨

    https://youtu.be/dKgIqe0x6Bc▾

    For more resources: 👉 Check out the blog post recap: https://lnkd.in/ebYdwdda 👉 Prisma Microsoft SQL Server Support is GA: https://lnkd.in/ezuEmwPS
    💯 2
    fast parrot 2
    prisma cool 2
  • y

    Yilmaz Ugurlu

    10/07/2021, 3:34 PM
    Can’t we add custom indexes to our tables out of schema file? It says here: https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#index
    While you cannot configure these option in your Prisma schema, you can still configure them on the database-level directly.
    Bu when I do and run
    migrate
    I get:
    Copy code
    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.
    
    [*] Changed the `event` table
      [+] Added index on columns (created_at, event_name)
      [+] Added index on columns (created_at, event_name)
      [+] Added index on columns (created_at, event_name)
    So, what am I doing wrong here? Any idea?
    r
    • 2
    • 10
  • j

    Julia Cassemiro

    10/07/2021, 3:41 PM
    Hii, someone know why i get this error?
    y
    • 2
    • 7
  • e

    Evan McDaniel

    10/07/2021, 4:06 PM
    Hi, new Primsa-er (Prisma-ite?) here. Enjoying working with it so far, but wanted to get some best practice advice from the community. Many of the models in our app are likely to have a large number of simple fields (just the nature of our domain), so mirroring the model data between the
    schema.prisma
    and Nexus
    schema.ts
    files will become tedious for our team pretty quickly. It seems that the Prisma Nexus plugin might help with this, but it looks to be in some sort of in-between state. I looked at TypeGraphQL as well but wasn’t sure if that actually would solve this specific issue. It looks like Pal.js might do solve this, though, so I wondered if that’s what folks are considering a best practice for this at the moment. Also have heard others say that maintaining separation between database and gQL schemas is actually the best practice, though I’ve yet to come up against a use case in our app that makes this clear. Open to all thoughts and ideas. Thanks!
    r
    • 2
    • 2
  • k

    Kamran Tahir

    10/07/2021, 6:24 PM
    In total, graphql in backend node Js is a total pain work on
  • k

    Kamran Tahir

    10/07/2021, 6:25 PM
    Too much verbosity, plus all the code first libraries need models and things etc etc
  • k

    Kamran Tahir

    10/07/2021, 6:25 PM
    And I dont exactly like the way nexus or gqtx or giraphql structure their functions
    r
    • 2
    • 1
  • j

    Jin

    10/07/2021, 8:19 PM
    Hello guys I am looking for someone who can manage my mobile app service in order to make it as a good product and promote it. It would be nice if you are in Germany. feel free to send me DM
    r
    • 2
    • 1
  • y

    Yashu Mittal

    10/08/2021, 5:17 AM
    how can I do something like this in prisma
    LOWER(db_column) LIKE LOWER(?)
    it is easy to lowercase the right part, but how to lowercase the left part before matching the value
    r
    • 2
    • 2
  • a

    Adam Herbert

    10/08/2021, 5:32 AM
    Hey guys, I'm new here and new to Prisma. I would love some help, I am building a workout app using Prisma and MySQL and I'm struggling with designing the schema. I basically am unsure how to allow users to complete a workout and store their results. I have made a post with my initial models - https://stackoverflow.com/questions/69490891/workouts-app-schema-for-mysql-using-prisma. Any help or advice would be much appreciated.
    d
    • 2
    • 4
  • u

    user

    10/08/2021, 6:54 AM
    GraphQL Pagination using Nexus and Apollo Client 3

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

    In this video, you'll learn how to add support for Pagination on the Server using Nexus and how to send a paginated query using Apollo Client Timestamps: 00:00 - Pagination at the database level using Prisma 03:57 - What a paginated GraphQL query looks like 7:03 - Creating Object types to follow the Relay Pagination spec 9:55 - Updating the resolver to support Pagination 21:20 - Sending paginated query using Apollo Client Useful links: • Pagination Overview in GraphQL: https://graphql.org/learn/pagination/ • GraphQL Pagination Relay Spec: https://relay.dev/graphql/connections.htm • 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 👉 Previous video: GraphQL Pagination using Apollo Client and on the Server -

    https://www.youtube.com/watch?v=NaxQXClnYSE&amp;list=PLn2e1F9Rfr6k6MwzS-p9FGK1NDBxxwLPk&amp;index=18&amp;pp=sAQB▾

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

    user

    10/08/2021, 12:31 PM
    Prisma Korea Meetup: Hyo Chan Jang: Migrate your database & switch to Prisma with Prisma introspect

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

    👉 데이터베이스 마이그레이션 및 prisma introspection 을 통한 prisma로의 손쉬운 전환발표자 : 장효찬. dooboolab이라는 회사의 founder이며 prisma korea co-founder로서 meep up 행사를 진행하고 있습니다. 또한 커뮤니티를 통한 Wehack 해커톤 행사를 주관하고 있습니다. -------------- Hyo Chan Jang (@Hyo) is the Founder of dooboolab, an IT agency based in Seoul, host of the WeHack hackathon, and the co-founder of the Prisma Korea Meetup. ✨ Join our Prisma Meetup group here: Join our Prisma Meetup group here: https://www.meetup.com/prisma-meetup-korea/ Next: 👉 Check Next video: Using Nestjs and Prisma for production -

    https://youtu.be/S6a1nganMbg▾

    🇰🇷 2
    prisma cool 2
    prisma rainbow 3
    👏 1
  • p

    Prince

    10/08/2021, 12:40 PM
    Hi guys, is there a way to add a callback function when a record is created/updated? Similar to what they have in Strapi.
    r
    l
    • 3
    • 4
1...491492493...637Latest