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

    Pedro Bonamin

    07/13/2022, 1:29 PM
    Hi! Is there a correct way to validate that the user has permissions to modify an entry? I'm a app that has a products CRUD Each product belongs only to one user. Which will be the correct way to validate that the product that will be modified, belongs to the user? I'm currently fetching the product, validating the user is correct, and then updating the product. But can this be done in the same update mutation? Something like this?
    ✅ 1
    r
    y
    • 3
    • 5
  • f

    Fiqri Syah Redha

    07/13/2022, 1:30 PM
    Hi, I got this error, I don't know why because my schema is valid and it sync with my database
    ✅ 1
    a
    • 2
    • 2
  • s

    spohl

    07/13/2022, 3:06 PM
    Is there a specific reason why the prisma client doesn't create any "where" args at all?
    r
    • 2
    • 2
  • t

    Tam Carre

    07/13/2022, 3:30 PM
    getting the following error reported. does anyone know what could be causing it? or, how can i investigate in further depth what this is coming from?
    Copy code
    Raw query failed. Code: `1064`. Message: `You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1` Error: Raw query failed. Code: `1064`. Message: `You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1`
    👀 1
    a
    • 2
    • 6
  • g

    Gezim

    07/13/2022, 5:21 PM
    I’m changing my table names to match the implicit in-between-table naming conventions: https://www.prisma.io/docs/concepts/components/prisma-schema/relations/many-to-many-relations#conventions-for-relation-tables-in-implicit-m-n-relations Is it normal to get this scary diff warning?
    Copy code
    It should be understood as the set of changes to get from the expected schema to the actual schema.
    
    [+] Added tables
      - _RecipeToFilterOption
    
    [-] Removed tables
      - recipes_filters_join
    
    [*] Changed the `_RecipeToFilterOption` table
      [+] Added unique index on columns (A, B)
      [+] Added index on columns (B)
      [+] Added foreign key on columns (A)
      [+] Added foreign key on columns (B)
    
    [*] Changed the `recipes_filters_join` table
      [-] Removed foreign key on columns (recipeFilterOptionId)
      [-] Removed foreign key on columns (recipeId)
    ✅ 1
    • 1
    • 3
  • k

    karolis

    07/13/2022, 6:43 PM
    👋 What are the proper patterns to update the database entities relations within rest API? I.e I want to remove the
    amenity
    from particular
    chalet
    Is this is how I do it?
    Copy code
    await prisma.chalet.update({ where: { id }, data:{ amenities: { disconnect:{ id }}}});
    Can/should I do it other way around? (disconnecting chalet from amenity)? I'm confused What my rest api route should look like? do I target
    chalet
    or
    amenity
    ? My sample schema:
    Copy code
    model Chalet {
      id           String    @id @unique @default(cuid())
      bookings     Booking[]
      reviews      Review[]
      amenities    Amenity[]
    }
    y
    • 2
    • 1
  • v

    Vanessa Kroeker

    07/13/2022, 6:50 PM
    Hi there! I'm having an issue with marking down migrations as resolved. I've followed the documentation on generating and applying the down migration with no issues, until I come to the
    npx prisma migrate resolve --rolled-back 20220713234002_some_migration
    step. When I try to use this to record that the migration has been rolled back, I get the error
    Copy code
    Error: P3012
    
    Migration `20220713234002_some_migration` cannot be rolled back because it is not in a failed state.
    Currently running Prisma v3.15.2.
    ✅ 1
    a
    • 2
    • 4
  • h

    Halvor

    07/13/2022, 7:17 PM
    Is it possible to use both a .sql file and a .ts file to seed the database, can i have multiple "seed" entries?
    ✅ 1
    y
    • 2
    • 2
  • s

    Schalk Neethling

    07/13/2022, 9:07 PM
    Hey folks! General question. When naming models, is it most common to use singular or plural? For example,
    model Difficulty
    or,
    model Difficulties
    . I kinda think the singular is stuck in my head because of the Django ORM, but I am not sure 🙂
    ✅ 1
    y
    • 2
    • 2
  • r

    Rene Melo

    07/13/2022, 9:08 PM
    Does Prism support select with "*with (nolock)*"? How to use "with (nolock)", usually used in select in SQL Server in Prisma?
    ✅ 1
    a
    • 2
    • 1
  • j

    Jannik Köster

    07/14/2022, 9:04 AM
    Copy code
    Type error: Property 'subscription' does not exist on 
    type 'PrismaClient<PrismaClientOptions, never, RejectOnNotFound | RejectPerOperation | undefined>'.
    As soon as i try to deploy to vercel, i get an error that subscription does not exist. but everything works fine in development, im using the same db for development and production(for now). Can someone help me here why this is happening. If i build locally for production this is working aswell.
  • j

    Jannik Köster

    07/14/2022, 9:04 AM
    Copy code
    datasource db {
      provider = "postgresql"
      url      = env("DATABASE_URL")
    shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
    }
    
    generator client {
      provider        = "prisma-client-js"
    
    }
    
    model Account {
      id                 String  @id @default(cuid())
      userId             String
      type               String
      provider           String
      providerAccountId  String
      refresh_token      String?  @db.Text
      access_token       String?  @db.Text
      expires_at         Int?
      token_type         String?
      scope              String?
      id_token           String?  @db.Text
      session_state      String?
    
      user User @relation(fields: [userId], references: [id], onDelete: Cascade)
    
      @@unique([provider, providerAccountId])
    }
    
    
    model Session {
      id           String   @id @default(cuid())
      sessionToken String   @unique
      userId       String
      expires      DateTime
      user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)
    }
    
    model User {
      id            String    @id @default(cuid())
      name          String?
      email         String?   @unique
      password String?
      emailVerified DateTime?
      image         String?
      accounts      Account[]
      sessions      Session[]
      role  Role    @default(USER)
      payments    Payment[] 
    }
    enum Role {
      USER
      PREMIUM
      ADMIN
    }
    
    model VerificationToken {
      identifier String
      token      String   @unique
      expires    DateTime
    
      @@unique([identifier, token])
    }
    
    model Payment {
            id           String   @id @default(cuid())
            orderID String
            status  String
            price String
            user User @relation(fields: [userId], references: [id], onDelete: Cascade)
            userId String       
    }
    
    model Subscription {
      id           String   @id @default(cuid())
      price       String 
      text       String
      description String
    }
    This is my schema
    👀 1
    a
    v
    • 3
    • 3
  • s

    shahrukh ahmed

    07/14/2022, 9:58 AM
    What is the recommended way to query a dateTime field when you want posts created/edited on a particular date?
    ✅ 1
    a
    • 2
    • 9
  • n

    NEERAJ SAMEER ALLU

    07/14/2022, 10:54 AM
    I have foreign key constraints on postgres. And when I use prisma transaction to push data to two tables with two prisma queries, its throwing error (violating foreign key constraints). Is there a way to solve it
    👀 1
    a
    v
    • 3
    • 2
  • s

    Slackbot

    07/14/2022, 3:38 PM
    This message was deleted.
    👀 1
    a
    • 2
    • 1
  • t

    Timothy Choi

    07/14/2022, 10:21 PM
    Hi, are there any packages out there that parses a querystring and transform them into Prisma queries?
    ✅ 1
    n
    • 2
    • 1
  • r

    Richard Ku

    07/15/2022, 1:37 AM
    anyone can help here? I am using prisma 3.15 I did db pull from my database and there is no error but when we did prisma generate it throws error
    Copy code
    error: No such argument.
      -->  schema.prisma:326
       | 
    325 | 
    326 |   @@index([eway_txn_id], Map: "consolidated_eway_txn_id_idx")
    it looks like it doesn't understand
    Map: "consolidated_eway_txn_id_idx"
    but it was generated by the prisma db pull. I tried to check the doc about @@index, but I cannot find info about the Map parameter. But I assume if it is created by the db pull, it should be valid? Please advise. Thanks.
    ✅ 1
    l
    • 2
    • 2
  • t

    Tri Nguyen

    07/15/2022, 2:42 AM
    hi, I need some help my database is like this
    Copy code
    User <-> UserPost <-> Post
    So user and post are many-to-many and I explicit state a table called userpost in between. How can I select user that is linked with post? My initial try is
    Copy code
    prisma.post.user.findMany({
        where: {
             links: {// I called the middle table link in schema
                  every: {
                       post: myPost,
                  }
             }
        }
    })
    but I don’t think that’s what I should do since it’s filtering. Can someone help me out
    ✅ 1
    m
    • 2
    • 2
  • v

    Vignesh T.V.

    07/15/2022, 5:32 AM
    Hi. A quick question - Are date filters supported in Postgres JSON field types via Prisma? I want to check if the value of the respective property in JSON is > current date
    ✅ 1
    n
    v
    • 3
    • 4
  • o

    Oscar Stahlberg

    07/15/2022, 9:59 AM
    Hey 👋 I am just integrating Prisma in our workflow and have a question about the CLI commands and where in our CI/CD to run them.
    npx prisma db pull
    for example needs to connect to the database which is running inside of our Kubernetes cluster. As we are using TLS certificates to authenticate the client (node app in this example) with the database, we don’t have access to those certificates in our build process. Where should I run those commands? Am I missing something here? Similar question about
    npx prisma migrate deploy
    . Thank you for your help!
    ➕ 1
    ✅ 1
    j
    d
    • 3
    • 9
  • a

    Arthur Roberto Fronza

    07/15/2022, 12:42 PM
    Good morning people! I have a quick question about the version 3 of prisma.. I’m trying to use graphql subscriptions on it but I’m not able to find the $subscription property inside prisma, was it deprecated?
    👀 1
    n
    • 2
    • 2
  • b

    Brothak

    07/15/2022, 2:15 PM
    What’s recommended way for seeding data with prisma? I saw few scripts around. Feels like you need to do a lot of stuff by hand. I mean you have to truncate table , reset sequences? and then load data fresh?
    ✅ 1
    c
    n
    • 3
    • 5
  • m

    Maciej Błędkowski

    07/15/2022, 7:29 PM
    Hi, to do something like
    [key: String]: String
    , but in Prisma? I use mongoDB as a database
    ✅ 1
  • m

    Maciej Błędkowski

    07/15/2022, 7:30 PM
    What I mean by this is that I want to be able to create any field in document
    ✅ 1
    n
    • 2
    • 3
  • d

    Danily

    07/15/2022, 8:23 PM
    Hello! Wondering if there's a workboard one can use to track Github issues to see if they've been prioritized / roadmapped (like https://github.com/prisma/prisma/issues/4703)
    ✅ 1
    n
    • 2
    • 1
  • a

    Aaron Dye JR

    07/16/2022, 9:16 AM
    Hey guys, I am currently facing a rather interesting issue with
    @prisma/client
    . Here are the current errors relating to the index.d.ts https://www.toptal.com/developers/hastebin/ojenalanoh.md. I am wondering if I should downgrade or if I am missing something
    👀 1
    n
    • 2
    • 2
  • r

    Rainer Lang

    07/16/2022, 5:08 PM
    Are there any blueprints/best practices for implementing RBAC/ABAC access authorization on a database level for Prisma (e.g. as part of schema definitions or query interceptors)?
    ✅ 1
    o
    y
    n
    • 4
    • 6
  • m

    Max Blancarte

    07/17/2022, 9:55 PM
    Hello If I have the following structure, when I create the model it can be an Array or it has to be defined as JSON?
    Copy code
    const persons = [
    	{
    		id: 'cblablabla',
    		name: 'John',
    		relatives: [
    			{ id: '1', name: 'Sara' },
    			{ id: '2', name: 'Bob' },
    		],
    	},
    	{
    		id: 'cblebleble',
    		name: 'Sara',
    		relatives: [
    			{ id: '1', name: 'John' },
    			{ id: '3', name: 'Bob' },
    		],
    	},
    ];
    
    model People {
      id        String   @id @default(cuid())
      name      String
      relatives String[] or JSON ?
    }
    ✅ 1
    y
    a
    • 3
    • 5
  • l

    Logic

    07/18/2022, 2:18 AM
    Im very new to database structures and I'm having a difficult time understanding how the
    type
    keyword can only be used for mongo db. The only other way I can find to doing it is by creating another model and just linking it to the same id of the main model, but that just plunders when you have many other objects in the schema. nvm ill ask a question on the github
    👀 1
    n
    • 2
    • 2
  • s

    Szabi Hetei-Bako

    07/18/2022, 4:36 AM
    Hi everyone. I need some help. I am using Prisma with tRPC in a NextJS project. There is a build error on Vercel complaining about implicit any during the build phase of the pipeline. I have no errors when I build the project locally. Also the types are correctly inferred in development. I don't want to use ignoreBuildErrors: true in my next config, obviously :) Did anyone encounter the same issue before? Thanks for your help
    ✅ 1
    y
    • 2
    • 2
1...597598599...637Latest