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

    user

    10/19/2021, 9:25 AM
    What's new in Prisma (v3.3.0)

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

    Daniel and Niko from the Prisma team discuss the latest 3.2.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.
  • s

    Suhani Shah

    10/19/2021, 12:06 PM
    @Ryan, I wanted to store createdDate (with specific timezone) in 
    test
     table for column 
    createdDate
     but in my case issue is graphql automatically convert into UTC, so, It store UTC date in DB Also I tried with custom resolver to modify UTC into company timezone but still it stores UTC value, because of the prisma I think
    Copy code
    let date = dayjs().tz(authenticated.companyTimezone).format('YYYY-MM-DD HH:mm:ss') (OUTPUT "2021-10-19T13:42:00+02:00")
    const payload = {
          ...data,
          CreatedDate: date,
        }
        return prisma.Test.create({
          data: payload,
          ...select,
        })
    So, again prisma convert into UTC because of 
    +02.00
     in above date value.
    r
    • 2
    • 3
  • m

    Mark

    10/19/2021, 1:18 PM
    Hey guys, last time we ran
    npx prisma format
    it automatically added
    @unique
    to some of our foreign key columns. Whilst this might be beneficial for some, this automatic addition of directive prohibits us from re-using our featured image across Recipes.
    r
    • 2
    • 5
  • u

    user

    10/19/2021, 1:33 PM
    JS Monthly #17: Ben Butterworth - Anonymous Video Calling App Using Machine Learning

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

    By turning on the webcam during video calls, we reveal our face, identity, race/ ethnicity, disabilities and living conditions. We also don't always feel like putting our camera on when talking to other people over video calls. We are also unusually quiet (or muted) when listening to someone on these calls. What if we could have video calls, but still avoid all these issues? Anonymous video calls allow you to communicate with someone using your facial expression and animation, without revealing your identity, physical background or other sensitive information. It allows you to safely share expressions and emotions. Your webcam feed is processed locally, sending only the minimal amount of data that represents your virtual face. You can try it at https://github.com/ben-xD/club/ The JS Monthly Meetup was organised by Aris Markogiannakis (JS Monthly host) and hosted by Prisma. ✨ Join the Prisma Meetup group here: https://www.meetup.com/js-monthly/ Follow Ben on Twitter: https://twitter.com/orth_uk Next: 👉 Check Next video: Heavily Connected Data Applications -

    https://youtu.be/D7C-97HgXTs▾

  • c

    Conor Wade

    10/19/2021, 3:37 PM
    Hey all, any idea why Prisma is adding an
    order by id ASC
    clause to this:
    const answers = await prisma.answer.findMany({
    take: 50,
    where: {
    questionId: questionId,
    },
    select: {
    body: true,
    response: {
    select: {
    year: true,
    unit: {
    select: {
    id: true,
    name: true,
    },
    },
    },
    },
    },
    })
    (Edit: Please ignore this, as I am an idiot. Order is needed for the limit offset to work)
    ✅ 1
  • y

    Yaakov

    10/19/2021, 3:57 PM
    Is there a way to preview the
    prisma db seed
    command? In other words, to get all the insert statements without actually running them?
    a
    • 2
    • 3
  • j

    Julien Goux

    10/19/2021, 5:52 PM
    Congrats for the last release with Cloudflare support!
  • j

    Julien Goux

    10/19/2021, 5:53 PM
    So I guess using the data proxy makes the rust binary very light? So it’s also a win for classic lambdas?
    m
    • 2
    • 1
  • j

    Julien Goux

    10/19/2021, 5:53 PM
    Is there a size comparison somewhere? 🙂
    m
    • 2
    • 1
  • y

    Yaakov

    10/19/2021, 6:45 PM
    My seeds are running in the wrong order which is causing this error:
    "No 'State' record(s) (needed to inline the relation on 'Facility' record(s)) was found for a nested connect on one-to-many relation 'FacilityToState'."
    . How can I control the order in which my tables seed? Here is my code: seed.js
    Copy code
    require('./seeds/stateSeeder');
    require('./seeds/facilitySeeder');
    stateSeeder.js
    Copy code
    const faker = require('faker/locale/en_US');
    const prisma = require('../client');
    
    async function main() {
      const states = faker.definitions.address.state;
      const stateAbbrs = faker.definitions.address.state_abbr;
      const data = states.map((state, i) => ({ name: state, abbr: stateAbbrs[i] }));
    
      await prisma.state.createMany({ data });
    }
    
    main()
      .catch((e) => {
        console.error(e);
        process.exit(1);
      })
      .finally(async () => {
        await prisma.$disconnect();
      });
    facilitySeeder.js
    Copy code
    const prisma = require('../client');
    
    async function main() {
      await prisma.facility.create({
        name: 'Name',
        address: '123 Broad St',
        city: 'Chicago',
        zip: '60652',
        state: {
          connect: { abbr: 'IL' }
        }
      });
    }
    
    main()
      .catch((e) => {
        console.error(e);
        process.exit(1);
      })
      .finally(async () => {
        await prisma.$disconnect();
      });
    client.js
    Copy code
    const { PrismaClient } = require('@prisma/client');
    const prisma = new PrismaClient({ log: ['query'] });
    
    module.exports = prisma
    c
    • 2
    • 3
  • r

    Ronit Rahaman

    10/19/2021, 6:51 PM
    Hello
    👋 3
  • t

    Tyler Bell

    10/19/2021, 7:37 PM
    Can someone explain to me the pros of Prisma 3 over 2? My team is currently using v2, but not sure the advantages of upgrading.
    a
    • 2
    • 2
  • m

    Moh

    10/19/2021, 10:25 PM
    Hi guys, hoping someone can help with a quick question. Is it possible to conditionally add an upsert? That is, if a certain array was passed in the payload, add the upsert to my top-level update statement? Eg: if payload.children.map below was undefined, how can I run the below query without an error?
    Copy code
    prisma.parent.update({
       name: "Bob",
       age: 30,
       children: {
          upsert: payload.children.map(child => (
             where: { id: child.id },
             create: { ... },
             update: { ... }
          ))
       }
    })
    b
    • 2
    • 19
  • b

    Bruno Marques

    10/19/2021, 10:27 PM
    so when using CPanel, my server is a Centos7, to host a Next.js Project with Node.js and Prisma. how do I setup prisma for this? will I be able to manipulate the database from node.js same as locally?
    r
    • 2
    • 1
  • g

    Gabe O'Leary

    10/19/2021, 11:54 PM
    I'd like to set up my models with an optional relation. This is what my
    schema.prisma
    file looks like:
    Copy code
    model User {
      idStr String @id 
      name String?
      statuses Status[]
    }
    
    model Status {
      idStr String @id
      createdAt DateTime
      userIdStr String
      user User? @relation(fields: [userIdStr], references: [idStr])
    }
    But I get this error:
    Copy code
    Foreign key constraint failed on the field: `Status_userIdStr_fkey (index)`
    when I try to create a status that has a
    userIdStr
    for which there is no corresponding
    User
    . How do I set up my models such that there doesn't have to be a
    User
    present for a given
    Status.userIdStr
    ?
    h
    m
    r
    • 4
    • 6
  • a

    Akshay Kadam (A2K)

    10/20/2021, 6:47 AM
    Why is
    Cascade
    not working?
    Copy code
    Error: Schema parsing
    error: No such argument.
      -->  schema.prisma:26
       | 
    25 | 
    26 |   user User @relation(fields: [userId], references: [id], onDelete: Cascade)
       | 
    error: No such argument.
      -->  schema.prisma:36
       | 
    35 |   expires      DateTime
    36 |   user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)
       | 
    
    Validation Error Count: 2
  • a

    Akshay Kadam (A2K)

    10/20/2021, 6:48 AM
    I am trying to make
    prisma
    work with
    next-auth
    by following steps suggested here → https://next-auth.js.org/adapters/prisma
  • a

    Akshay Kadam (A2K)

    10/20/2021, 6:49 AM
    But it's giving error near
    onDelete: Cascade
  • a

    Akshay Kadam (A2K)

    10/20/2021, 6:50 AM
    Oopsies I got it. The error is because I'm using v2.23.0 & prisma supports it from v2.26.0
    ✅ 1
  • u

    user

    10/20/2021, 6:54 AM
    JS Monthly #17: Daniel Olavio Ferreira - Heavily Connected Data Applications

    https://www.youtube.com/watch?v=D7C-97HgXTs▾

    In my talk, I will be showing how complex it can get when having to deal with SQL table relations with some mainstream ORMs, such as TypeORM and Sequelize. I will compare them to how Prisma deals with it using a simple yet powerful schema syntax, and an intuitive query client. The JS Monthly Meetup was organised by Aris Markogiannakis (JS Monthly host) and hosted by Prisma. ✨ Join the Prisma Meetup group here: https://www.meetup.com/js-monthly/ Follow Daniel: Github: https://github.com/danielolaviobr/ Twitter: https://twitter.com/danielolaviobr Next: 👉 Check Next video: Double up your component & integration tests with Supertest & Nock -

    https://youtu.be/ku4gX69D3xA▾

    👉 Check Previous video: Anonymous Video Calling App Using Machine Learning -

    https://youtu.be/lO4f3Acx1_4▾

  • r

    Rene Nielsen

    10/20/2021, 7:13 AM
    ⚠️ Help needed: ⚠️ I tried reading the documentation as much as possible. I am though hitting some kind of wall, when trying to lookup multiple scenarios for what later will be FullTextSearch when that is supported in mongodb.
    Copy code
    let filter = {
          include: {
            category: true,
            instructor: true,
            lections: true,
          },
          where: {
            OR: [
              {
                title: {
                  startsWith: search,
                  mode: 'insensitive',
                },
              },
              {
                title: {
                  contains: search,
                  mode: 'insensitive',
                },
              },
              {
                description: {
                  startsWith: search,
                  mode: 'insensitive',
                },
              },
              {
                description: {
                  contains: search,
                  mode: 'insensitive',
                },
              },
            ]
          }
        };
    I get the following Typescript error. (Using Prisma 3.3.0)
    Copy code
    Argument of type '{ include: { category: boolean; instructor: boolean; lections: boolean; }; where: { OR: ({ title: { startsWith: any; mode: string; contains?: undefined; }; description?: undefined; } | { title: { contains: any; mode: string; startsWith?: undefined; }; description?: undefined; } | { ...; } | { ...; })[]; }; }' is not assignable to parameter of type '{ select?: CourseSelect | null | undefined; include?: CourseInclude | null | undefined; where?: CourseWhereInput | undefined; orderBy?: Enumerable<...> | undefined; cursor?: CourseWhereUniqueInput | undefined; take?: number | undefined; skip?: number | undefined; distinct?: Enumerable<...> | undefined; }'.
      The types of 'where.OR' are incompatible between these types.
        Type '({ title: { startsWith: any; mode: string; contains?: undefined; }; description?: undefined; } | { title: { contains: any; mode: string; startsWith?: undefined; }; description?: undefined; } | { description: { ...; }; title?: undefined; } | { ...; })[]' is not assignable to type 'Enumerable<CourseWhereInput> | undefined'.
          Type '({ title: { startsWith: any; mode: string; contains?: undefined; }; description?: undefined; } | { title: { contains: any; mode: string; startsWith?: undefined; }; description?: undefined; } | { description: { ...; }; title?: undefined; } | { ...; })[]' is not assignable to type 'CourseWhereInput[]'.
            Type '{ title: { startsWith: any; mode: string; contains?: undefined; }; description?: undefined; } | { title: { contains: any; mode: string; startsWith?: undefined; }; description?: undefined; } | { description: { ...; }; title?: undefined; } | { ...; }' is not assignable to type 'CourseWhereInput'.
              Type '{ title: { startsWith: any; mode: string; contains?: undefined; }; description?: undefined; }' is not assignable to type 'CourseWhereInput'.
                Types of property 'title' are incompatible.
                  Type '{ startsWith: any; mode: string; contains?: undefined; }' is not assignable to type 'string | StringFilter | undefined'.
                    Type '{ startsWith: any; mode: string; contains?: undefined; }' is not assignable to type 'StringFilter'.
                      Types of property 'mode' are incompatible.
                        Type 'string' is not assignable to type 'QueryMode | undefined'.ts(2345)
    r
    • 2
    • 10
  • t

    Tobias Lins

    10/20/2021, 7:43 AM
    Just saw the new version 3.3.0, this is huge! 🔥 Love what you did with the Proxy and Prisma available within Cloudflare Workers, this might change a lot. Are there any limitations of the proxy when it’s production ready? Will it be a paid service?
    j
    d
    +2
    • 5
    • 11
  • m

    Moh

    10/20/2021, 10:30 AM
    Hi all - I am wanting to update an entity that has a one-to-many relationship with another. The UI sends me an array of objects, I want those objects inserted and any previous objects related to that entity removed. What is the correct way of doing this with Prisma? Disconnect?
    r
    • 2
    • 2
  • e

    Edward Baer

    10/20/2021, 1:34 PM
    I just upgraded to Prisma 3.2.1. Seems that it broke some of my code I where I was calling a Stored Procedure using the $executeRaw call. Does anyone know how to call a StoredProcedure and get a result back now ? This is what I was doing:
    const getSequenceBlock = async (sequenceName, addCount = 1) => {
     
    let data = false;
     
    try {
    st [callGetSequenceBlock, getStartEnd] = await prisma.$transaction([
          `prisma.$executeRaw(
    CALL GetSequenceBlock('${sequenceName}', ${addCount}, @start, @end);
    ),`       `prisma.$queryRaw(
    SELECT @newSeqStart, @newSeqEnd FROM DUAL;
    ),
    Copy code
    ]);`    
    // Successful result comes back as [ { '@newSeqStart': 146, '@newSeqEnd': 151 } ]
       
    if (Array.isArray(getStartEnd)) {
         
    const row = getStartEnd[0];
         
    if (typeof row === 'object') {
           
    data = {
             
    start: row['@newSeqStart'],
             
    end: row['@newSeqEnd'],
           
    };
         
    }
       
    }
     
    } catch (error) {
       
    throw error;
     
    }
     
    return data;
    };
    r
    • 2
    • 11
  • c

    Chip Clark

    10/20/2021, 2:47 PM
    Getting the Unknown arg error - even though I'm passing an int as requested. Do my fields need unique identifiers? Error:
    Copy code
    Unknown arg `id` in data.id for type MainSidebarUpdateInput. Available args: 
                                                                                 
    type MainSidebarUpdateInput {                                                
      Main_Sidebar?: String | NullableStringFieldUpdateOperationsInput | Null    
    }                                                                            
                                                                                 
     +34621ms                                                                    
    Error:                                                                       
    Invalid `prisma.mainSidebar.update()` invocation:                            
                                                                                 
    {                                                                            
      where: { ID: 1 }
    service:
    Copy code
    async updateMainSidebar(params: {
        where: Prisma.MainSidebarWhereUniqueInput;
        data: Prisma.MainSidebarUpdateInput;
      }) {
        const { where, data } = params;
        return this.prisma.mainSidebar.update({
          where,
          data
        });
      }
    controller:
    Copy code
    @Put(`${Route}/:id`)
      async update(
        @Param('id', ParseIntPipe) ID: number,
        @Body() data: Prisma.MainSidebarUpdateInput
      ) {
        return this.mainSidebarService.updateMainSidebar({
          where: { ID },
          data,
        });
      }
    schema
    Copy code
    model MainSidebar {
      ID           Int     @id @default(autoincrement())
      Main_Sidebar String? @db.VarChar(Max)
    }
    Application side error:
    Copy code
    HttpErrorResponse: {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":500,"statusText":"Internal Server Error","url":"<http://am-web11:3060/api/sidebar/1>","ok":false,"name":"HttpErrorResponse","message":"Http failure response for <http://am-web11:3060/api/sidebar/1>: 500 Internal Server Error","error":{"statusCode":500,"message":"Internal server error"}}
    a
    • 2
    • 2
  • r

    Reuben Porter

    10/20/2021, 4:45 PM
    Hi, has anyone experienced the dreaded
    Copy code
    Error querying the database: db error: FATAL: sorry, too many clients already
    error?
    a
    r
    • 3
    • 56
  • r

    Reuben Porter

    10/20/2021, 4:46 PM
    I've tried everything in this thread https://github.com/prisma/prisma/issues/1983
  • p

    Perry Raskin

    10/20/2021, 5:00 PM
    is there any practical difference between doing
    { userId: 50 }
    and
    { User: { connect: { id: 50 } } }
    ?
    a
    • 2
    • 2
  • p

    Perry Raskin

    10/20/2021, 5:02 PM
    doing
    { userId: 50 }
    is only allowed in v2.11.0 and above? is that all?
  • m

    Michael Aubry

    10/20/2021, 9:45 PM
    In my app https://motionbox.io I am randomly getting
    The provided value for the column is too long for the column's type
    the error is straightforward. What I don’t understand is when writing to the same table with the same data in my session it works, but in my employees session he is getting this error. I have noticed this inconsistency quite often. I am using Vercel serverless functions to interface with PostgreSQL so maybe there is a connection pool issue? We’re starting to grow and have one of the most amount of concurrent users I’ve seen. So I think its a serverless concurrency issue/ Any ideas? This video seems like it may be helpful

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

1...496497498...637Latest