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

    Efren Palacios

    08/20/2021, 11:14 PM
    Anyone know when the next series is going to be added? ๐Ÿ˜ฎ https://www.prisma.io/blog/fullstack-nextjs-graphql-prisma-oklidw1rhw
  • s

    Shubh _

    08/21/2021, 2:25 AM
    Hi, team I am working (currently working on design) on a FOSS side project multi-tenant application where each tenant is given a separate Postgres database. Let's assume the following are database connection URLs. Tenant Foo: postgres://postgres:PASS@localhost:5432/ten_foo/ Tenant Bar: postgres://postgres:PASS@localhost:5432/ten_bar/ Requirement 1: Now, whenever a user asks for a resource. I first call a "Tenant Context Service" to get the database URL. Now I want to use it to fetch the data. Shall I dynamically change the data source (as shown in https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#datasources)? Will it have any performance impact, considering that I want to use connection pooling? Requirement 2: I have a total of 24 relations. And every tenant shares the same set of relations except one. In one relation (or table) namely UserProfile, the tenant can customize the columns. (For example: Say tenant A wants UserProfile to have "Name", "Age", "Years of Experience" and tenant B wants UserProfile to have ("First Name", "Last Name", "Age")).
    Note: There is another table to store the metadata like Age is a number, First Name is a String. And all these things are enforced by triggers etc. In other words, for every column in UserProfile (say first_name) I have another table (say UserProfileFields) where I store the meta information on "first_name". Whenever a new row is added/edited to UserProfileFields corresponding changes are reflected in UserProfile column using row level triggers.
    Should I still use Prisma, considering the variable nature of the schema of UserProfile relation? I am new to system design etc, and I apologise for any silly design flaws. I would be very grateful if I could get any inputs. Thank you.
    r
    r
    • 3
    • 4
  • n

    Nathaniel Babalola

    08/21/2021, 10:48 AM
    I noticed prisma didn't generate all the different types for my models after the first Model I created (I am using JavaScript). The first Model I created was called User, and when I saw the intellisense on
    prisma.user
    I was impressed, I have gone on to create 9 more models after this and the only thing it suggests is the other model names
    await prisma.modelname
    , after this there's no types again once you start using
    create
    ,
    findMany
    ..e.t.c When I hover my mouse over , it just shows type
    any
    Can someone please help me out on how to fix this, it prevents me from making some errors as I know what method and properties are safe to use
    r
    • 2
    • 25
  • r

    Robin

    08/21/2021, 11:10 AM
    how do I access the type of a specific model? E.g. I am getting a user collection passed via props (nextjs), how do I specify the type of it?
    r
    • 2
    • 5
  • k

    Khammassi HoussemEddine

    08/21/2021, 4:32 PM
    Hello everyone I'am a backend engineering enthusiast and liked the concept of prisma
  • k

    Khammassi HoussemEddine

    08/21/2021, 4:33 PM
    my questions is : is there a students related mentorship and internship programs at prisma ? cause the opportunities i saw are mostly senior related ?
    ๐Ÿ™Œ 3
  • y

    Yashua Pervez

    08/21/2021, 5:36 PM
    Hi
    ๐Ÿ‘‹ 1
  • s

    Shubh _

    08/22/2021, 11:28 AM
    Hi Prisma team. Will there be any support for Cassandra in future?
    r
    • 2
    • 1
  • s

    Slackbot

    08/22/2021, 1:00 PM
    This message was deleted.
    k
    ั‚
    • 3
    • 2
  • g

    glekner

    08/22/2021, 3:05 PM
    can I have a generic mutation that deletes a resource? something like
    _await_ ctx.prisma?.[resourceType].delete()โ€ฆ
    r
    • 2
    • 1
  • g

    glekner

    08/22/2021, 3:05 PM
    typescript doesnโ€™t like it
  • j

    Jaye

    08/23/2021, 9:20 AM
    i'm trying to run some cypress tests on a next.js app using prisma. i'd like to run a prisma seed file before the tests run, so i can be sure there is predictable test data in the db. in
    /cypress/plugins/index.js
    i have:
    Copy code
    const seedDb = require("../../prisma/seed.js")
    
    module.exports = on => {
      on("task", {
        resetDb: async () => {
          await seedDb()
          return true
        },
      })
    }
    which works fine, but my prisma seed file can't find the database url: ๐Ÿ˜ž
    Copy code
    const { PrismaClient } = require("@prisma/client")
    const prisma = new PrismaClient()
    
    const main = async () => {
      // make stuff here
    }
    
    main()
      .catch(e => {
        console.error(e)
        process.exit(1)
      })
      .finally(async () => {
        await prisma.$disconnect()
      })
    
    module.exports = main
    i'm invoking it using a command like this in my npm scripts, like the docs suggest
    Copy code
    "cypress": "dotenv -e .env.test next dev & cypress open",
    and i have a
    .env.test
    file defined with a working
    DATABASE_URL
    string. what am i doing wrong?
    r
    • 2
    • 1
  • u

    user

    08/23/2021, 10:04 AM
    Setting up a PostgreSQL database

    https://www.youtube.com/watch?v=7ihvEtBAjRYโ–พ

    Blog Post: https://www.prisma.io/blog/fullstack-nextjs-graphql-prisma-oklidw1rhw Code: https://github.com/m-abdelwahab/awesome-links 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
  • t

    Tobias Lins

    08/23/2021, 10:41 AM
    I just found out why my typescript autocomplete was so slow all the time. When you setup prisma like following https://www.prisma.io/docs/guides/performance-and-optimization/connection-management#prevent-hot-reloading-from-cre[โ€ฆ]-new-instances-of-prismaclient Typescript gets barely useable. I replaced it with basic
    export const prisma = new PrismaClient();
    and all performance issues were resolved. Should I create a ticket for that?
    r
    • 2
    • 1
  • t

    Tarik Brat

    08/23/2021, 10:47 AM
    Hi Guys, how can I get all rows including specific word in one column. Example: column_name(varchar): "This is just a test", return if column_name includes "test"
    r
    • 2
    • 2
  • b

    benjick

    08/23/2021, 12:35 PM
    Hello. I have a field with
    Json
    but when I try to write data to it I get the following error:
    Type 'OrderOutput[]' is not assignable to type 'InputJsonValue'.
    I thought Json should be able to take any valid json. Pasting the interface in the thread ๐Ÿ‘‰
    r
    f
    • 3
    • 6
  • u

    user

    08/23/2021, 1:19 PM
    Prisma Meetup Korea

    https://www.youtube.com/watch?v=qKqSRTtOlmwโ–พ

    Prisma Meetup Korea is an online event aiming to connect, inform and empower the Korean developers. Join with other local engineers to discuss the latest database and API developments and learn more about Prisma best practices. This event has been created in cooperation with dooboolab (https://dooboolab.com) - an IT agency based in Seoul. Speakers: โ—ญ Hyo Chan Jang โ—ญ Han Sangjin โ—ญ Jed Watson ๐Ÿ‡ฐ๐Ÿ‡ท ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ best practice, ํ”„๋ฆฌ์ฆˆ๋งˆ์˜ ๋™์ž‘์›๋ฆฌ, ํ”„๋กœ๋•์…˜ ๋ ˆ๋ฒจ์—์„œ์˜ ํ”„๋ฆฌ์ฆˆ๋งˆ ์˜ˆ์ œ ๋“ฑ ํ”„๋ฆฌ์ฆˆ๋งˆ์— ๋Œ€ํ•ด ์ข€ ๋” ์•Œ๊ณ ์ž ํ•˜์‹œ๋Š” ๋ถ„์€ ๊ฐ ์ง€์—ญ์˜ ํ”„๋ฆฌ์ฆˆ๋งˆ ์—”์ง€๋‹ˆ์–ด๋ง ์ปค๋ฎค๋‹ˆํ‹ฐ์— ์ฐธ์—ฌํ•˜์„ธ์š”. ์ด๋ฒˆ ๋ฐ‹์—…์—์„œ 3๋ช…์˜ ๋ฐœํ‘œ์ž ๋ถ„๋“ค์ด ์žˆ์œผ์‹ญ๋‹ˆ๋‹ค. ํ•œ์ƒ์ง„ : Wonderwall ๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ์ž ์žฅํšจ์ฐฌ : dooboolab founder Jed Watson : The Thinkmill co-founder, KeystoneJs ์ œ์ž‘์ž Meetup Group: https://www.meetup.com/prisma-meetup-korea/ ๐ŸŽ ์ด๋ฒคํŠธ ๊ธฐ๊ฐ„๋™์•ˆ ์ถ”์ฒจ์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๋†€๋ผ์šด ์„ ๋ฌผ๋“ค์„ ์–ป์„ ๊ธฐํšŒ๋ฅผ ๋†“์น˜์ง€ ๋งˆ์„ธ์š”. ์šฐ๋ฆฌ๋Š” ๋ฒ ๋ฅผ๋ฆฐ ์ฝ”๋“œ ์ปจ๋ฒค์…˜์„ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค. https://berlincodeofconduct.org/ 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
    ๐Ÿ‘ 2
  • b

    benjick

    08/23/2021, 1:20 PM
    What does this error mean?
    Foreign key constraint failed on the field:
    Print_userId_fkey (index)
    I tried googling but I couldn't find any good explanation. Is it because some tables have Int as id while others have String?
    r
    • 2
    • 5
  • u

    user

    08/23/2021, 7:48 PM
    Why closed captions and how easy is to add them to your video

    https://www.youtube.com/watch?v=nWOem4ax4u4โ–พ

    Adding close captions to your YouTube videos is a small inclusive step that can have a significant impact for a large portion of your audience. In this video, Nika Musiฤ‡ covers why adding closed captions is important and how it can benefit you. Prisma sponsors high-quality, human-reviewed, professional closed captions for ANY video that benefits our community (for example, Node.js, TypeScript & Type Safety, Prisma, databases, etc.). Learn more and get your FREE captions here: https://pris.ly/closedcaptions 0:38 - Benefits of closed captions: 1๏ธโƒฃ Wider Audience 2๏ธโƒฃ SEO Benefits 3๏ธโƒฃ Higher view time and engagement 4๏ธโƒฃ Mitigated audio issues ------------------------ ๐Ÿ“š 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: โ—ญ Website: https://www.prisma.io โ—ญ Docs: https://www.prisma.io/docs โ—ญ Quickstart: https://pris.ly/qstart ------------------------ ๐Ÿ’ฌ 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
  • r

    Robin

    08/24/2021, 6:53 AM
    I have the following model in my schema with CASCADE set:
    Copy code
    model Solve {
      user   User @relation(fields: [userId], references: [id], onDelete: Cascade)
      userId Int
    
      challenge   Challenge @relation(fields: [challengeId], references: [id], onDelete: Cascade)
      challengeId Int
    
      createdAt DateTime @default(now()) @map(name: "created_at")
    
      @@id([userId, challengeId])
    }
    r
    • 2
    • 13
  • r

    Robin

    08/24/2021, 6:53 AM
    Now when I am trying to delete a user with
    prisma.user.delete({where:...})
    , I get the following error: `The change you are trying to make would violate the required relation 'SolveToUser' between the
    Solve
    and
    User
    models.`
  • r

    Robin

    08/24/2021, 6:53 AM
    Why is that? I thought the cascade will take care of this.
  • d

    Dev__

    08/24/2021, 7:39 AM
    hello, is it possible to say that a field can be 1 or more relations? example
    Copy code
    referenceId Int
    
    ========
    model A
    
    model B
    
    model C
    how can I say that
    referenceId
    can be either
    A
    ,
    B
    or
    C
    r
    d
    • 3
    • 9
  • r

    Robin

    08/24/2021, 9:24 AM
    I have the following model (which was suggested by next-auth):
    Copy code
    model Account {
      id                 Int       @default(autoincrement()) @id
      compoundId         String    @unique @map(name: "compound_id")
      userId             Int       @map(name: "user_id")
      providerType       String    @map(name: "provider_type")
      providerId         String    @map(name: "provider_id")
      providerAccountId  String    @map(name: "provider_account_id")
      refreshToken       String?   @map(name: "refresh_token")
      accessToken        String?   @map(name: "access_token")
      accessTokenExpires DateTime? @map(name: "access_token_expires")
      createdAt          DateTime  @default(now()) @map(name: "created_at")
      updatedAt          DateTime  @default(now()) @map(name: "updated_at")
    
      @@index([providerAccountId], name: "providerAccountId")
      @@index([providerId], name: "providerId")
      @@index([userId], name: "userId")
    
      @@map(name: "accounts")
    }
    How do I delete an entry by specifing a userId now? I tried this
    Copy code
    await prisma.account.delete({
        where: {
          userId: userId,
        },
      });
    which results in
    Type '{ userId: number; }' is not assignable to type 'AccountWhereUniqueInput'.
    l
    r
    d
    • 4
    • 13
  • s

    See Jee

    08/24/2021, 11:39 AM
    Can someone welcome me?
    ๐Ÿ‘‹ 4
  • i

    inlightmedia

    08/24/2021, 1:34 PM
    For prisma1 on version 1.34.12, the
    npx prisma1 introspect
    and
    npx prisma1 init
    both do nothing. Iโ€™m using all the correct database connection data (these same connection data work perfectly when using psql to connect). Iโ€™m running these both from the same folder where I use
    npx prisma1 deploy
    successfully daily. When the interactive cli data entry tool reaches the last question (the ssl question) it just seems to quit, return to the cli and leaves no errors, no output and no introspected datamodel file. Any ideas?
  • i

    inlightmedia

    08/24/2021, 1:59 PM
    Are the createdAt and updatedAt fields required in the data model for datamodel v1.1. In v1.0 they were implicitly available but hidden, when queried. Now when updating to the new datamodel v1.1 the prisma deploy output warns it will delete (and cause data loss) all createdAt and updatedAt fields from the database because they are not explicitly in the datamodel. In order to not lose data, do I need to add createdAt and updatedAt to every single type in my data model explicitly now with v1.1?
  • ั‚

    ะขะพัˆะต

    08/24/2021, 2:20 PM
    Can i get clarification regarding the @Prisma/client and prisma Prisma aka prisma/cli is a dev dependency and is not required in production When running it inside a docker container without prisma/cli and without running prisma generate first i get this error
    Copy code
    Error: @prisma/client did not initialize yet. Please run \"prisma generate\" and try to import it again.\nIn case this error is unexpected for you, please report it in <https://github.com/prisma/prisma/issues>\n at new PrismaClient (/usr/app/node_modules/.prisma/client/index.js:3:11)\n at /usr/app/main.js:28701:20\n at Plugin.exec (/usr/app/node_modules/avvio/plugin.js:132:19)\n at Boot.loadPlugin (/usr/app/node_modules/avvio/plugin.js:267:10)\n at Task.release (/usr/app/node_modules/fastq/queue.js:149:16)\n at worked (/usr/app/node_modules/fastq/queue.js:201:10)\n at /usr/app/node_modules/avvio/plugin.js:270:7\n at done (/usr/app/node_modules/avvio/plugin.js:202:5)\n at check (/usr/app/node_modules/avvio/plugin.js:226:9)\n at node:internal/process/task_queues:141:7","type":"Error","msg":"@prisma/client did not initialize yet. Please run \"prisma generate\" and try to import it again.\nIn case this error is unexpected for you, please report it in <https://github.com/prisma/prisma/issues>"}
    prisma/cli is required to run prisma generate
    r
    • 2
    • 4
  • i

    Irakli Safareli

    08/24/2021, 4:37 PM
    If you have
    COMMENT ON Table foo is "bla bla"
    in PG database. Will prisma pull then use that comment in prisma file like this?:
    Copy code
    /// bla bla
    model foo {
    ...
    }
    • 1
    • 1
  • g

    Giorgio Delgado

    08/24/2021, 4:56 PM
    Just saw thereโ€™s full text search in the latest release of prisma, will this eventually be available for MySQL?
    n
    • 2
    • 1
1...473474475...637Latest