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

    Jarupong

    09/25/2022, 9:11 AM
    please share your error log
    h
    n
    • 3
    • 3
  • j

    Joey

    09/25/2022, 3:22 PM
    say I want to fetch all the content belonging to 1 user, and nest the user in the result set:
    const blogs = await prisma.blogs.findMany({where: { userId }, include: {user:true}});
    is prisma / sql smart enough so that it won’t do a join on every single one of the results, since it will always be the same userId/user? if not, is it recommended to just fetch that user once in a separate query?
    ✅ 1
    n
    • 2
    • 1
  • a

    Ashe Magalhaes

    09/25/2022, 4:26 PM
    Hey all, question: We're finding that prisma is timing out (server is closing) on transactions with a high number of relations. Is there a fix for this? We're considering just removing the relation field - have folks run into this?
    ✅ 1
    n
    • 2
    • 2
  • d

    David Van Isacker

    09/26/2022, 1:04 AM
    Curious: https://prisma.slack.com/archives/CA491RJH0/p1663897717470129 Is this a known issue ? Should i submit a ticket on github ?
    ✅ 1
    n
    • 2
    • 1
  • y

    Yudhvir Raj

    09/26/2022, 2:07 AM
    Hi, I love Prisma & have been using it for a while! I am switching from PostgreSQL to Cockroach DB (seamless thanks to Prisma!!) & wanted to know if the configuration is different. Specifically do I require the data proxy: https://www.prisma.io/data-platform/proxy. Since CockroachDB has Serverless features do I require the proxy. With PostgreSQL I can understand why I would need it. Would love thoughts on this
    ✅ 1
    j
    n
    • 3
    • 6
  • y

    Yudhvir Raj

    09/26/2022, 2:11 AM
    @andrewicarlson https://prisma.slack.com/archives/C0MQBSAJY/p1662900428793269?thread_ts=1662898930.641479&cid=C0MQBSAJY I was reading this, so the Data Proxy is for Prisma opening connections. So would I require this when working with Cockroach DB serverless? I'm fairly new to Serverless so these may be basic questions.
    ✅ 1
    n
    • 2
    • 8
  • d

    David Ilizarov

    09/26/2022, 5:27 AM
    Is this accurate? The TypeScript shows I could do stuff like:
    Copy code
    prisma.model.update({
      where: {
        id: 10
      },
      data: {
        array: {
          push: [1,2,3,4]
        }
      }
    })
    The above would presumably push 4 numbers onto the array on my model. The documentation says otherwise below
    ✅ 1
    n
    • 2
    • 2
  • a

    A. Sauder

    09/26/2022, 6:51 AM
    Hello Is there any way from prism itself to generate classes instead of type? Especially for the automapper I would need classes.
    ✅ 1
    n
    y
    • 3
    • 5
  • t

    thomas dicola

    09/26/2022, 8:50 AM
    Hi have you ever seen this message before ? Downloading Prisma engines for darwin-arm64 [ ] 0%Error: Not Found “https://binaries.pri ....... etc with a commit number/querry-engine.gz” it happens when i use this commande
    ✅ 1
    n
    • 2
    • 1
  • t

    thomas dicola

    09/26/2022, 8:50 AM
    npx prisma migrate dev --name init
    ✅ 1
    n
    • 2
    • 3
  • r

    Rémi

    09/26/2022, 9:16 AM
    My goal is to get every TutelageClass where the user is not already registered to the next session. The solution displayed at the end always shows every TutelageClass. I'm trying to execute the following query with Prisma :
    Copy code
    SELECT a.id, a.title
    FROM a
    INNER JOIN ON a.nextSession = b.id
    INNER JOIN ON b.id = c.tutelageSession
    INNER JOIN ON c.user = d.id
    WHERE d.name NOT 'VALUE';
    Here my tables : | a (TutelageClass) | b (TutelageSession) | c | d (User) | | ------------------- | ----------------------- | ----------------------- | --------- | | id | id | #user | id | | title | title | #tutelageSession | name | | #nextSession | My Prisma schema is the following (simplified) :
    Copy code
    datasource db {
      provider = "mongodb"
      url      = env("DATABASE_URL")
    }
    
    model TutelageClass {
      id                   String  @id @default(auto()) @map("_id") @db.ObjectId
      title                String
    
      nextSessionId String? @db.ObjectId
      nextSession TutelageSession?
    }
    
    model TutelageSession {
      id         String   @id @default(auto()) @map("_id") @db.ObjectId
    
      registeredStudentsIDs String[] @db.ObjectId
      tutelageClassId       String   @unique @db.ObjectId
    
      tutelageClass      TutelageClass @relation(fields: [tutelageClassId], references: [id], onUpdate: Cascade, onDelete: Restrict)
      registeredStudents User[]        @relation("RegisteredStudentsToTutelageSession", fields: [registeredStudentsIDs], references: [id])
    }
    
    model User {
      id            String    @id @default(auto()) @map("_id") @db.ObjectId
      name          String?
    
      registeredToTutelageSessionIDs String[] @db.ObjectId
    
      registeredToTutelageSession TutelageSession[] @relation("RegisteredStudentsToTutelageSession", fields: [registeredToTutelageSessionIDs], references: [id])
    }
    And finally, the code I'm trying :
    Copy code
    const c = await client.tutelageClass.findMany({
        select: {
            id: true,
            title: true,
        }, where: {
            nextSession: {
                registeredStudents: {
                    none: {
                        id: userIdNotRegistered
                    }
                }
            }
        }
    });
    v
    n
    • 3
    • 10
  • b

    Bablu Ahmed

    09/26/2022, 9:59 AM
    Is there someone to help me?
    ✅ 1
    j
    a
    • 3
    • 6
  • r

    Ricardo Ferreira

    09/26/2022, 10:24 AM
    Hi everyone 👋 I just want to ask, how can I drop all the migrations through CLI? I tried
    prisma migrate reset
    but that recreates all the migrations and I just want to be able to trash all the migrations
    ✅ 1
    n
    • 2
    • 4
  • m

    Matheus Assis

    09/26/2022, 12:03 PM
    is grapql nexus dead? Prisma-plugin never got updated. The channel was deleted…
    ✅ 1
    n
    • 2
    • 1
  • v

    Vladi Stevanovic

    09/26/2022, 1:15 PM
    This question was answered here: https://prisma.slack.com/archives/CA491RJH0/p1664186378323559
  • m

    Mordechai Tzarfati

    09/26/2022, 3:07 PM
    can anyone help? im trynig to create tests on my system with feature tests and unit, i want to create a rollback hook so once a test starts it creates a transaction and when it ends, it rollsback. i saw so many issues with transactions on prisma, hoping someone would have way to do such thing here.
    ✅ 1
    n
    s
    • 3
    • 7
  • n

    Nurul

    09/26/2022, 3:25 PM
    From @Ashe Magalhaes
    Hi there! New to this channel so please redirect me if this should go elsewhere.
    I’m using prisma with a mysql planetscale backend.
    I’m getting an error about ROW_NUMBER() in a
    prisma.$queryRaw
    Something like this, which works fine on my planetscale console:
    Copy code
    const query = `select ROW_NUMBER() over() FROM contacts`;
    Results in the error:
    Copy code
    Code: `1105`. Message: `unknown error: syntax error at position 26`
    Anyone know why prisma can’t seem to handle
    ROW_NUMBER()
    function?
    ✅ 1
    r
    a
    • 3
    • 3
  • v

    Vladi Stevanovic

    09/26/2022, 3:34 PM
    From @Gourave Verma
    Hey all, I'm trying to use prisma along with this article to create a multi tenant application. I have everything setup, but when I try to migrate, I can't create tables in other schemas in my database.
    When I try to run a query like
    .create
    I get an error like
    Copy code
    The table `e874649f-ac3e-47c0-bbd5-994fdd7dc116.User` does not exist in the current database.
    which makes sense.
    Im new to prisma so I was wondering if anyone had any ideas on how I could create the tables specified in
    schema.prisma
    in my db when I run migrate
    ✅ 1
    n
    g
    • 3
    • 4
  • p

    Peter

    09/26/2022, 4:21 PM
    https://www.prisma.io/docs/concepts/components/prisma-client/filtering-and-sorting#sort-by-relation Does this only work when the relation is 1-to-1? Am I correct in assuming the
    orderBy
    clause does not take into account the relations joined with
    include
    and
    where
    ?
    ✅ 1
    n
    • 2
    • 1
  • m

    MrDrummer25

    09/26/2022, 7:13 PM
    Anyone got some insight into this? I am still at a loss. Any help would be appreciated.
    ✅ 1
    n
    • 2
    • 3
  • n

    Nathan

    09/26/2022, 7:17 PM
    Hey Everyone! I’ve searched all over to find an answer for this but havent found a solution that quite seems to work. I’ve developed a nodejs express server and am deploying it to elastic beanstalk with a postgres db as a production environment. In the elastic beanstalk configuration of environment variables, I set DATABASE_URL to the correct url of the amazon db. For whatever reason though, the schema.prisma file is unable to read the environment variable being injected by elastic beanstalk. I’d like to avoid having to commit an env for each environment local, dev, prod, etc. What would be the recommended course of action? Thank you in advance for any advice 🙂
    Copy code
    Error: Schema validation error - Error (query-engine-node-api library)
    Error code: P1012
    error: Environment variable not found: DATABASE_URL.
      -->  schema.prisma:12
       | 
    12 |   url = env("DATABASE_URL")
       | 
    
    Validation Error Count: 1
    [Context: getConfig]
    
    Prisma CLI Version : 4.3.1
    ✅ 1
    j
    n
    • 3
    • 6
  • s

    sean oreilly

    09/26/2022, 8:48 PM
    Hey all! I am having some difficulty with seeding my database (Forgive me I am a little bit new). I am trying to create a modal Vote, but I keep getting an error `Unique constraint failed on the fields: (
    userId
    )` • the thing that is confusing to me is that I have other modals that are setup very similarly and this is just causing me a lot of confusion. This is my code:
    Copy code
    const fakers = await Promise.all(
        new Array(10).fill(1).map(async () => {
          return {
            email: faker.internet.email(),
            name: faker.name.fullName(),
            id: faker.datatype.string(),
            username: faker.internet.userName(),
            image: faker.internet.avatar(),
          }
        })
      )
    
      const fakeUsers = await Promise.all(
        fakers.map(async (user) => {
          return prisma.user.upsert({
            where: { email: user.email },
            update: {},
            create: {
              email: user.email,
              name: user.name,
              image: user.image,
              username: user.username,
            },
          })
        })
      )
    
      const suggestions = await Promise.all(
        fakeSuggestions.map(async (suggestion, i) => {
          return prisma.suggestion.upsert({
            where: { title: suggestion.title },
            update: {},
            create: {
              title: suggestion.title,
              description: suggestion.description,
              user: {
                connect: {
                  id: fakeUsers[Math.floor(Math.random() * fakeUsers.length)].id,
                },
              },
              category: {
                connect: {
                  id: cats[Math.floor(Math.random() * cats.length)].id,
                },
              },
              status: {
                connect: {
                  type: stats[Math.floor(Math.random() * stats.length)].type,
                },
              },
            },
          })
        })
      )
    
      // Votes
      await Promise.all(
        new Array(100).fill(1).map(async (i) => {
          return prisma.vote.upsert({
            where: {
              id: Math.floor(Math.random() * 1000),
            },
            update: {},
            create: {
              user: {
                connect: {
                  id: fakeUsers[Math.floor(Math.random() * fakeUsers.length)].id,
                },
              },
              suggestion: {
                connect: {
                  id: suggestions[Math.floor(Math.random() * suggestions.length)]
                    .id,
                },
              },
            },
          })
        })
      )
    ✅ 1
    n
    v
    • 3
    • 5
  • s

    sean oreilly

    09/26/2022, 8:48 PM
    If anyone could help me that would be amazing
    ✅ 1
    n
    • 2
    • 1
  • n

    Nathan N

    09/26/2022, 9:54 PM
    hi what would cause the "Add record" button in Prisma Studio to be disabled? I have a many-to-many Mongo relationship with two models and I can't create records for either of them. The rest are working fine
    ✅ 1
    n
    v
    • 3
    • 7
  • e

    Eric Simon

    09/26/2022, 11:36 PM
    How are people with handling types where the response from a Prisma query is inferred? For example in the response from the following create, I want to explicitly type the response so that I can pass this throughout my application.
    Copy code
    // Inferred type:
    // User & {
    //   posts: Post[];
    // }
    const user = await prisma.user.create({
      data: {
        email: '<mailto:alice@prisma.io|alice@prisma.io>',
        password: '0ee4808f893b8e05bdd251048d5c4c8af8bb89403676dda95619841a481f8e87',
        name: 'Alice',
        posts: {
          create: {
            title: 'Learn how to use Prisma with TypeScript',
            content: '<https://www.prisma.io/docs/>',
          },
        },
      },
      include: {
        posts: true,
      },
    })
    ✅ 1
    n
    s
    • 3
    • 6
  • n

    Nurul

    09/27/2022, 11:02 AM
    Hey @Jake W 👋 Are you still facing this issue even after passing an ObjectID of length 12?
    j
    • 2
    • 1
  • n

    Nurul

    09/27/2022, 11:30 AM
    Seems related to this thread: https://prisma.slack.com/archives/CA491RJH0/p1664206100743379 Let me know if fixing the root cause didn’t fix this issue as well.
  • m

    Muhammed Hafiz

    09/27/2022, 11:48 AM
    I have a mongodb schema like this intended to support multiple language input,
    {
    "_id": {
    "$oid": "61cd48ae528ffa2b3e44010e"
    },
    "name": {
    "en": "Arwa Water 24 X 500ml",
    "ar": "AR content ",
    },
    "description": {
    "en": "Stay hydrated in a healthy way with this water, It is sure to quench your thirst and nourishes your body with all the essential vitamins and minerals"
    },
    *mrp*: 17,
    *stock*: 100,
    *packing*: "24"
    }
    Currently i use
    mongoose
    and
    mongoose-intl
    to retrieve language only data like this according to the language set, is it possible to achieve this with Prisma? if not, what are the alternatives?
    {
    "_id": {
    "$oid": "61cd48ae528ffa2b3e44010e"
    },
    "name":  "Arwa Water 24 X 500ml",
    "description": "Stay hydrated in a healthy way with this water, It is sure to quench your thirst and nourishes your body with all the essential vitamins and minerals",
    *mrp*: 17,
    *stock*: 100,
    *packing*: "24"
    }
    ✅ 1
    v
    n
    • 3
    • 7
  • t

    Timo

    09/27/2022, 11:52 AM
    What NodeJS server framework do you recommend for using prisma?
    ✅ 1
    v
    n
    n
    • 4
    • 9
  • d

    doddy nicolas

    09/27/2022, 2:54 PM
    hi everyone
1...625626627...637Latest