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

    Juan Carlos Blanco Delgado

    01/09/2022, 11:15 PM
    Does prisma has its own caching? I continue reading about caching conflict so I want to make sure I know the limitations and I need to implement my own caching mechanism
    n
    • 2
    • 3
  • d

    Dregond

    01/10/2022, 5:06 AM
    hey, anyone experinceing a problem where Data Proxy created a db connection with api_key null? prisma://aws-us-east-1.prisma-data.com/?api_key=null
    h
    • 2
    • 2
  • m

    Mradul Jain

    01/10/2022, 8:53 AM
    hello everyone how i can connect views with a prisma models
    h
    n
    • 3
    • 3
  • e

    ericsonluciano

    01/10/2022, 10:31 AM
    does
    next-auth
    have support for
    user.role
    enum? i'm planning to add Admin / User permission based on the doc it not possible with prisma adapter
  • u

    user

    01/10/2022, 6:15 PM
    Free captions for everyone! #shorts #inclusion

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

    👏 1
  • s

    Stephen Jensen

    01/11/2022, 12:39 AM
    Hey everyone! I’m wondering if you can help me, I made a number of changes to my schema and actually migrated from an older version of Prisma to 2.30.3 (yes still old, but better than it was!). I’m getting the error
    Could not find the migration file at /app/prisma/migrations/dev/migration.sql. Please delete the directory or restore the migration file.
    Is there a programmatic way to handle resolving this error? The command that I’m running to get me to this point is:
    npx prisma migrate dev -n dev
    which connects to a postgres container running in the cluster. I’m running this at a few sites where some of them have fresh databases so this error won’t happen there, but those with existing databases have this error. A partial solution I came up with is to run
    npx prisma reset -f
    which is not ideal because it resets everything but has the further complication that I'd need to somehow run the migrate command and then based on the status code run this reset command which isn't the best solution.
    t
    • 2
    • 6
  • a

    Adrian

    01/11/2022, 9:47 AM
    Hi, I want to want to have an 1:n relationship (
    aThing
    , 
    bThing
    ). But the data comes async over a eventbus. So it can happen, that 
    aThing
     trys to reference an ID from 
    bThing
    , that is currently not there. How can I describe this in the schema, so that I dont get an `Foreign key constraint failed on the field`error?
  • u

    user

    01/11/2022, 10:27 AM
    What's new in Prisma (v3.8.0)

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

    Alex from the Prisma team discusses the latest 3.8.0 release of Prisma and other news from the Prisma ecosystem. Tune in to learn about new releases, how to upgrade, planned features, and other interesting bits from the Prisma world.
    💚 2
  • v

    Vasily Zorin

    01/11/2022, 3:39 PM
    Upgrading from 3.6.0 to 3.8.0 gives me this:`Process finished with exit code 137 (interrupted by signal 9: SIGKILL)`
  • a

    Anand George

    01/11/2022, 4:00 PM
    I have a web form that allows upload of data for a specific table. The form passes in a file and a database table name. How do I create records using the create method passing in the table name as a string in the call to prisma create like so prisma[table_name].create
    k
    f
    • 3
    • 7
  • u

    user

    01/11/2022, 5:36 PM
    Prisma & PlanetScale Best Practices

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

    In this video, you will learn about everything you need to know when using Prisma with PlanetScale. We'll dive into: - Referential integrity and operating without foreign key constraints - Migration workflows with Prisma and PlanetScale using the
    prisma db push
    command - Defining indices on relation scalars (the foreign key fields). Timestamps: 00:00 Intro 00:41 The three best practices 03:34 Enabling and setting
    referentialIntegrity
    in the Prisma schema 04:59 Creating the PlanetScale database 05:44 Branching in PlanetScale 08:54 Creating a PlanetScale connection string 09:11 Creating the database schema with
    prisma db push
    09:37 Seeding the database with some data 10:04 Updating the Prisma schema and using native types to change the column type from VARCHAR to Text 11:54 Checking the data with Prisma Studio 12:37 Defining indices on relation scalars (the foreign key fields). 15:00 PlanetScale branching workflows 15:45 Promoting the main branch to production on PlanetScale 16:12 Creating a new branch to add more columns to the schema 18:05 Connecting to the
    add-created-at
    branch with the pscale connect command 19:08 Updating the DATABASE_URL env var in the .env file 20:12 Evolving the Prisma schema by adding more fields to the models 21:10 Running
    prisma db push
    to update the database schema of the branch 22:20 Creating a deploy request for the schema on PlanetScale 23:39 Deploying the deploy request 24:33 Recapping the branching workflow with a diagram 25:02 Tips for using Prisma and PlanetScale with Vercel 31:29 Summary
  • c

    Chip Clark

    01/11/2022, 11:11 PM
    Can't Filter subtable using date gt: I'm trying to filter records where an invoice date is greater than a horizon date. I get records back, but some of the vendors have invoice dates dating before the horizon (and none after). In other areas, I'm using filters on subtables, but none where the date can be used as a filter. where clause:
    Copy code
    const whereClause = {
          AND: [
            {
              InvoiceTransaction: {
                some: {
                  InvoiceDate: { gt: horizon }
                }
              }
            },
            {
          ...(searchString?
              {
                VendorName: { contains: searchString },
              }
          : {}),
            }
          ]
        }
    The schema
    Copy code
    model Vendor {
      VendorPKID          Int      @id @default(autoincrement())
      VendorUno           Int      @unique
      VendorNumber        Int?
      VendorID            String?  @db.VarChar(10)
      VendorName          String?  @db.VarChar(40)
      NameUno             Int?
      VendorTypeCode      String?  @db.VarChar(5)
      AddressUno          Int?
      Address1            String?  @db.VarChar(60)
      Address2            String?  @db.VarChar(60)
      City                String?  @db.VarChar(60)
      State               String?  @db.VarChar(5)
      PostalCode          String?  @db.VarChar(50)
      Note                String?  @db.VarChar(Max)
      Active              Boolean  @default(false)
      ActiveFromDate      DateTime @db.Date
      ModifiedDate        DateTime @default(now()) @db.DateTime
      ModifiedBy          String   @db.VarChar(30)
    
      InvoiceTransaction  InvoiceTransaction[]
    }
    Setting horizon to: 2020-01-11T000000.000Z or 2015-01-11T000000.000Z makes no difference. Both return the same records
    • 1
    • 2
  • c

    Chris Baucom

    01/12/2022, 6:02 AM
    👋 prisma rainbow 👪 - Let’s say I want to show 10 related posts at the bottom of an article based on that article’s title. I know you can do something like
    Copy code
    query relatedPosts {
       posts(where: { title: { contains: "Best Restaurants in New York" } }) {
          title
       }
    }
    but that only gets me other posts with that same title, How can I get related posts based on each word of the title? Maybe the 10 most recent “Best restaurants” or “Best New York” or “New York”? How should I be thinking about this? Any and all help is much appreciated 🙏
    f
    • 2
    • 2
  • v

    Viswa

    01/12/2022, 8:58 AM
    Hi this is Viswaprasath from India. I am planning to give a talk about Prisma (loved it from first time using it). Can anyone mentor me on what are the things I can share. Target Audience : Mostly College grads.
  • u

    ut dev

    01/12/2022, 10:42 AM
    Hi guys, I got a question. I defined my models in my schema.prisma file is it possible to automatically generate proper interface of my models?
    f
    h
    • 3
    • 4
  • a

    Anthony Rodriguez

    01/12/2022, 5:58 PM
    Hey, does anyone has experience deploying a Nuxt app on Vercel that also uses Prisma? I'm having an issue with it, it's telling me that prisma is not found and I'm really confused since I was reading github issues and I did what they advised to do, adding prisma generate to the postinstall hook but for some reason it doesn't work. Can anyone help me with that?
    t
    f
    • 3
    • 20
  • d

    Daniel De La Luz

    01/12/2022, 7:11 PM
    Hi, its posible prisma to Connect two servers (pgsql y mysql) in nestjs ?
  • m

    Max T

    01/12/2022, 7:56 PM
    `Null constraint violation on the fields: (
    id
    )` error when trying to make a new entry like this,
    Copy code
    const newTag = await prisma.user.update({
          where: { id: id },
          data: {
            tags: {          
              create: {
                name: tag,
              },
            },
          },
        });
    I'm unsure what is null, since the
    id
    field is the default, autogenerated field. Maybe it has something to do the with relation or schema, which I can provide upon request.
    b
    • 2
    • 29
  • g

    Gift Atte

    01/12/2022, 10:17 PM
    How to connect my sql on hared host
  • o

    Oyewole ABAYOMI S.

    01/13/2022, 1:06 AM
    Please, i need help. Is there a way for prisma groupBy set default value instead of returning empty array
    Copy code
    const i = await this.prisma.transactions.groupBy({
          by: ['status'],
          where: {
            status: { in: ['APPROVED', 'COMPLETED', 'PENDING'] }
          },
          _count: {
            status: true
          }
        })
    console.log(i) // []
    
    // i need something like
    // {approved: 0, pending: 0, completed: 0}
    Thank you.
  • a

    Alex Van Der Werff

    01/13/2022, 2:18 AM
    Howdy ! I’m trying to solve an issue where prisma fails to connect to a DB, and doesn’t retry. There’s an open issue on github here: https://github.com/prisma/prisma/issues/9420 but hasn’t had a lot of action. I’ve tried to reconnect to the db, but prisma complains when it tries to reconnect too many times:
    Copy code
    warn(prisma-client) There are already 10 instances of Prisma Client actively running.
    I tried to
    prisma.$disconnect()
    , but
    Copy code
    UnhandledPromiseRejectionWarning: Error: Can't reach database server at `localhost`:`3307`
    h
    • 2
    • 4
  • m

    mikkelsl

    01/13/2022, 9:29 AM
    Can anyone lead me towards a better way of getting statistics through prisma for making a chart?
    Copy code
    const now = new Date()
            const months = Array(6).fill(null)
    
            const statistics = months.map(async (_, i) => {
              const gte = getFirstDayOfMonth(now, i)
              const lte = getLastDayOfMonth(now, i)
              return ctx.db.event.count({ where: { dateFrom: gte, dateFrom: lte }})
            })
    
            const results = await Promise.all(statistics)
    s
    • 2
    • 8
  • m

    Mradul Jain

    01/13/2022, 10:16 AM
    hello, primsa model won't work without unique key?, In my on-premises database i don't have any unique key on it as well no primary constraint. how i can handle such situation
  • e

    Ezequiel Lowi

    01/13/2022, 11:19 AM
    Hello, We have a database with static data, such as questionnaire Q&As. Any idea if there's a method in prisma to add new data, say a new Question/Answer pair through a kind of migration? Like if it was possible to seed the db during the migration process, with new data.
  • n

    Nathaniel Babalola

    01/13/2022, 2:30 PM
    Please does Prisma have many to many via a join table ?
    t
    • 2
    • 2
  • a

    Alex Ruheni

    01/13/2022, 3:43 PM
    Hello friends 👋🏽 We’ll be going

    live -WNIP 3.8.0▾

    in T-17 minutes Feel free to drop by and join in the conversation 🙂
    👀 1
  • t

    Tyler Clendenin

    01/13/2022, 4:19 PM
    is there a way to pass arguments into the
    prisma db seed
    command to be used by the seed script?
    c
    • 2
    • 2
  • c

    Chris Baucom

    01/13/2022, 4:46 PM
    Hi prisma 👪 - I have a question about dev vs. prod databases. I have updated my prisma schema model and need to apply the changes to both databases. For dev, I typically run
    npx prisma generate
    which I think does the migration as well. I never notice issues locally on dev db. But when trying to push my changes to the prod db with
    npx prisma db push
    I am not convinced it fully worked as I can only see the new table I create but the columns for that table in other models are not showing up. For context here, I added a
    Comment
    model and added a
    comments
    field to my
    User
    and
    Post
    model. I see
    Comment
    table, but not
    comments
    in
    User
    or
    Post
    . Here is output of
    npx prisma db push
    Copy code
    Environment variables loaded from .env
    Environment variables loaded from prisma/.env
    Prisma schema loaded from prisma/schema.prisma
    Datasource "db": PostgreSQL database "demo-prisma-pool-stg", schema "public" at "<http://demo-prisma-db-stg-do-user-4493521-0.b.db.ondigitalocean.com:25061|demo-prisma-db-stg-do-user-4493521-0.b.db.ondigitalocean.com:25061>"
    
    🚀  Your database is now in sync with your schema. Done in 1.03s
    
    ✔ Generated Prisma Client (2.23.0) to ./node_modules/@prisma/client in 106ms
    ✔ Generated TypeGraphQL integration to ./graphql/generated/type-graphql in 5.32s
    Yes, I’m on Prisma 2.23.0. Any help is much appreciated as I try and grasp best practices here when making schema changes and pushing to prod 🙂
    t
    b
    • 3
    • 11
  • n

    Nathaniel Babalola

    01/13/2022, 6:38 PM
    Hi all , on PostgreSQL native type attributes of time
    Copy code
    @db.Time(x)
    What should be passed as
    x
    ? I don't understand it
    t
    • 2
    • 2
  • m

    Mradul Jain

    01/14/2022, 7:08 AM
    Hello everyone, I am getting an error, I have also checked it on internet but did not found any thing.
1...531532533...637Latest