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

    Adrian

    07/25/2022, 12:29 PM
    Well not just mine. The API of EVERYONE using Prisma since Decimal types get serialized to a string
  • v

    Vicente Matus

    07/25/2022, 5:06 PM
    Guys im currently using Prisma with MongoDB but i have the following problem
    Error: P1001
    `Can't reach database server at `cluster0...`:`27019`` `Please make sure your database server is running at `cluster0...`:`27019`.` Whenever i try to use
    npx prisma db pull
    in an existing MongoDB data base This is my DATABASE_URL
    mongodb+srv://<username>:<password>@<cluster>/<database>?retryWrites=true&w=majority
    I'm currently connected to MongoDB Atlas, and the cluster is allowing connections from all ip's. How can i solve this?
    👀 1
    a
    v
    • 3
    • 2
  • y

    Yunbo

    07/25/2022, 5:49 PM
    Create nested record. - How can i get another relation record id? https://www.prisma.io/docs/concepts/components/prisma-client/crud#create-a-deeply-nested-tree-of-records this is simplified version
    Copy code
    const u = await prisma.user.create({
      data: {
        email: '<mailto:emma@prisma.io|emma@prisma.io>',
        posts: {
          create: [
            {
              title: 'My first post',
              external_user_id: `a1b2c34d-{user.id}`
            }
          ],
        },
      },
    })
    about
    external_user_id
    , so how can i get user.id (that is being created in this query) dynamically?
    ✅ 1
    s
    • 2
    • 8
  • m

    Matt Mueller (Prisma Client PM)

    07/25/2022, 9:34 PM
    Has anyone had a chance to try the new Prisma Metrics API in 3.15.0 yet? • You can watch a demo video here:

    https://www.youtube.com/watch?v=B3Mh3yGRZ5U&amp;t=580s▾

    • Metrics documentation is here: https://www.prisma.io/docs/concepts/components/prisma-client/metrics Please let me know if you give it a go and what you think of it!
    🔥 2
    🙌 1
  • m

    Mordechai Tzarfati

    07/25/2022, 9:47 PM
    Hey guys! im having a question about prisma queries when it comes to many to many, lets say i have Products and Users products are generated by admins and users can have few products. products can also be owned by few users. what im trying to do is getting a single user, and getting his products, no success so far, any idea how i can do such thing?
    👀 1
    l
    • 2
    • 1
  • d

    Damon J. Murray

    07/25/2022, 10:14 PM
    Hello all - quick question. Is it possible to import the
    StringFilter
    type from prisma's deep input types? Am I forced to duplicate this type in my consuming project?
    ✅ 1
    n
    • 2
    • 2
  • m

    Michael Jay

    07/26/2022, 12:56 AM
    Question - and I'm afraid I know the answer. Let's say that I'm creating a bunch of contacts, and each contact may have attributes that belong in related tables (contact HAS MANY emails, contact HAS MANY tags...) I was hoping that I could create the contacts AND their related records in createMany...
    Copy code
    prisma.contact.createMany({
      data: [
        {
          ...contact attrs,
          tags: {
            create: {...}
          }
        }
      ]
    })
    and so forth. But it looks like that's only possible for create. so I'm guessing my two options are: 1. CreateMany the contacts, then match them back up with the input to get the right ID on the related records 2. Create (single) each contact with its related records in place. Maybe in a transaction/ Promise all. Am I missing something - are those my two options?
    ✅ 1
    a
    n
    • 3
    • 3
  • m

    mahmood sagharjooghi

    07/26/2022, 2:54 AM
    Hi everyone. Where should I run my migrations in production? I am using prisma and azure SQL database. I use github actions for deploying the backend to the app service. Backend is node express.
    👀 1
    a
    • 2
    • 1
  • y

    Yunbo

    07/26/2022, 3:25 AM
    what's the equivalent of SQL query for following? ( is there any function that transform prisma client query into SQL query? )
    accntId : 1, regionId: 1
    Copy code
    this.prisma.cidrBlock.findFirst({
      where: {
        vpcs: {
          none: {
            account_id: accntId,
            region_id: regionId,
          },
        },
      },
      orderBy: {
        id: 'asc',
      },
    });
    ✅ 1
    a
    n
    • 3
    • 5
  • j

    Jannik Köster

    07/26/2022, 8:15 AM
    hello, is there a prisma command to backup my database?
    ✅ 1
    n
    • 2
    • 1
  • m

    Mordechai Tzarfati

    07/26/2022, 1:19 PM
    when im trying to create a new user and the type of the Object is Users (model type), it requires to add
    id
    to the object, any way to avoid it?
    ✅ 1
    n
    • 2
    • 4
  • a

    Al

    07/26/2022, 1:28 PM
    Hello, 🙌 I'm developing an app that need to migrate database and generate an updated Prisma Client while running. I was able to migrate database and generate the client by calling the cli command using spawn function. The problem is that the PrismaClient instance is already in memory and is not updated with the new schema. Do you have some ideas about how to fix that?
    👀 1
    n
    • 2
    • 6
  • p

    Paul Obayuwana

    07/26/2022, 2:36 PM
    model Community { id String @id @default(cuid()) commName String? commType String? commAbout String? members User[] manager User @relation(fields: [managerId], references: [id]) managerId String @unique } Hello, I want to create a community schema. Like a group or channel that has many users. And has a user as the community manager. But I got this error error: Error validating model "Community": Ambiguous relation detected. The fields
    members
    and
    manager
    in model
    Community
    both refer to
    User
    . Please provide different relation names for them by adding `@relation(<name>). How do I go about this? Am new to prisma. I haven't understood the docs fully
    ✅ 1
    l
    n
    • 3
    • 3
  • t

    Thomas Yankue

    07/26/2022, 2:48 PM
    Hi there, I'm wondering what the best way to make a friendship system is? My current model looks like this
    Copy code
    model User {
      id      String  @id
      username String  @unique
    }
    And basically I want to tie together 2 users. Similar to just about every other app with a friends system, each user can have multiple friendships, but each friendship can only include 2 users. What is the best way to do this in Prisma with MySQL, in a way that I can easily list all friends of a given user? Thanks!
    ✅ 1
    j
    • 2
    • 12
  • t

    Thomas Yankue

    07/26/2022, 2:50 PM
    I tried having a
    friendship
    model that had an array of user IDs, or an array of users, but the problem was to fetch all of user A's friends, I could easily get all the IDs, but then I had to perform 1 query for each friend to fetch the whole user model. It worked but it seemed very inefficient - is there a better way or is this the only way it can work?
    👀 1
    l
    • 2
    • 1
  • v

    Viggo Jonasson

    07/26/2022, 6:37 PM
    Hello! I am new to slack so excuse any formatting issues. I am having difficulties writing my schema. Very new to SQL and relational databases (I am a long time mongodb user) 🙂 Any kind of help is appreciated.
    model TestUser {
    id String @id @default(cuid()) @unique
    name String
    madeReviews Review[]
    receivedReviews Review[]
    }
    model TestReview {
    id String @id @default(cuid()) @unique
    author TestUser @relation(_fields_: [authorId], _references_: [id])
    authorId String
    receiver TestUser @relation(_fields_: [receiverId], _references_: [id])
    receiverId String
    rating Int
    comment String
    }
    I basically just want to have a user that can make and get reviews.
    👀 1
    a
    • 2
    • 3
  • k

    Khelil Benosman

    07/26/2022, 6:44 PM
    Hello 🖖 I need some advice pls ! I am developing a blockchain monitoring dashboard. It’s an aggregator of several data streams: tweets, github statistics, etc...so I need to regularly request several api’s and store the result to make it available to another frontend...What is the best stack to use with Prisma for this kind of services ?
    ✅ 1
    k
    n
    n
    • 4
    • 18
  • k

    KJReactor

    07/26/2022, 7:15 PM
    I just updated to v4.1.0 and it seems that nested reads for a 1:1 relationship is not working. I'm using the Mongo connector. The FK side does not retrieve info even when I use
    include
    .
    👀 1
    ✅ 1
    a
    • 2
    • 4
  • p

    Pieter

    07/26/2022, 8:23 PM
    @janpio any thoughts on this discussion? We'd love to get our traces in datadog CC @Adam Haney
    ✅ 1
    n
    j
    • 3
    • 3
  • a

    Angel

    07/26/2022, 10:45 PM
    Hi! When should I use
    npx prisma generate
    ? I usually migrate my schemas using
    npx prisma migrate [...]
    , which I think also regenerates the Prisma Client, so what are other use cases for
    npx prisma generate
    ?
    ✅ 1
    n
    o
    • 3
    • 2
  • j

    João Vitor Casarin

    07/26/2022, 11:03 PM
    hey people, how you doing? so, I have this postgres database but I am completely unable to execute a simple
    TRUNCATE TABLE user RESTART IDENTITY CASCADE;
    ... everytime I try to run that on both
    prisma.$queryRaw
    and on pgadmin I get the same error: 42601 syntax error at or near to "user"
    ✅ 1
    n
    • 2
    • 8
  • j

    João Vitor Casarin

    07/26/2022, 11:03 PM
    any idea?
  • u

    user

    07/27/2022, 8:00 AM
    Announcing the Prisma FOSS Fund 3 min read Prisma has started a fund to support independent free and open source software teams. Each month, we will donate $5,000 to a selected project to maintain its work and continue its development.
    prisma rainbow 1
    🙌 2
  • p

    Paul Obayuwana

    07/27/2022, 1:24 PM
    I created a schema for a user who can choose either a to be community manger or member
    👀 1
    l
    • 2
    • 4
  • m

    Michael Jay

    07/27/2022, 2:22 PM
    Is there any easy workaround for EXCLUDING one field in a find? The only solution I see is using SELECT on all other fields - that could be a burden.
    ✅ 1
    n
    • 2
    • 2
  • m

    Michael Buller

    07/27/2022, 2:47 PM
    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.
    
    [+] Added tables
      - stage UserRole
    
    ? We need to reset the database.
    Do you want to continue? All data will be lost. » (y/N)
    
    Is there a way to tell Prisma to ignore a schema ?
    ✅ 1
    n
    • 2
    • 2
  • m

    Michael Buller

    07/27/2022, 2:48 PM
    You cant join between databases in the cloud so when bringing data into a database ie. migrating off of an old system, we have to land it locally, then Prisma instantly tries to delete everything.
  • i

    Isaac Spiegel

    07/27/2022, 5:22 PM
    Hello, I’m wondering what the best practice is for typing generic helper functions that can operate on any model delegate. Basically what I’m trying to do right now:
    Copy code
    export function paginatedFindMany<K>(
      delegate: PrismaDelegate<K>,
      where: PrismaWhereInput<K>,
      select ...
    ) {
      ...
    }
    It doesn’t look like the client exposes the interfaces needed to type this fully, I’m wondering if there’s another Prisma package or community generator that’s implemented these sorts of generic interfaces
    👀 1
    d
    • 2
    • 1
  • d

    Dave Edelhart

    07/27/2022, 6:25 PM
    https://www.prisma.io/docs/guides/performance-and-optimization/connection-management#prevent-hot-reloading-from-creating-new-instances-of-prismaclient --- the “global Prisma” example does not work any more - global variables under typescript; NodeJS.Global is not a thing anymore
    ✅ 1
    a
    • 2
    • 1
  • d

    Dave Edelhart

    07/27/2022, 6:35 PM
    Greetbots link is broken: “The best place to get help with a technical problem is on GitHub: • Ask a question
    ✅ 1
    n
    • 2
    • 1
1...600601602...637Latest