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

    febreeze

    11/23/2021, 9:07 PM
    question: the Schema Types from the client don’t include relational fields. Why is that? if i have an relation between things, and i include it, i get a lot of squiggles that are not true. Is there a setting to include them in the generate?
    l
    r
    • 3
    • 13
  • n

    n

    11/23/2021, 11:26 PM
    Hey all, how do I do a find on where with 2 enums?
    Copy code
    where: {
            applicationId: application.id,
            status: Status.REQUIRED || Status.PENDING,
          },
    r
    • 2
    • 1
  • n

    n

    11/23/2021, 11:27 PM
    status is either 2 of the enums
  • p

    Philipp Minder

    11/23/2021, 11:32 PM
    Hello. I dont really find out, how i deploy my express prisma app on Docker, that prisma create the Database tables on first run. Anyone have an idea? Thats my dockerfile:
    FROM node:latest
    # Create app directory WORKDIR
    /usr/src/app
    COPY _package.json_
    ./
    COPY _pnpm-lock.yaml_
    ./
    RUN _npm_
    install
    -g
    pnpm
    RUN _pnpm_
    install
    RUN _pnpm_
    install
    -g
    prisma
    COPY _._
    .
    EXPOSE
    8000
    RUN _pnpx_
    prisma
    generate
    CMD _[_ "npm"_,_ "run"_,_ "start:prod" _]_
    r
    • 2
    • 4
  • b

    Britt Danzer

    11/24/2021, 7:13 AM
    I have a prisma query that groups by dueDate:
    Copy code
    const data = await prisma.customer.groupBy({
            by: ['dueDate'],
            where: {
                status: {
                    in: 'PAID',
                },
                merchantId: 1
            },
            _sum: {
                balancePaid: true
            },
            orderBy: {
                dueDate: 'asc'
            }
        })
    And this is a sample of the return:
    Copy code
    [
        {
            "dueDate": "2021-11-01T06:30:26.387Z",
            "_sum": {
                "balancePaid": 27337.94
            }
        },
        {
            "dueDate": "2021-11-01T09:26:17.966Z",
            "_sum": {
                "balancePaid": 4320.82
            }
        },
        {
            "dueDate": "2021-11-01T09:43:23.207Z",
            "_sum": {
                "balancePaid": 50684.73
            }
        },
        {
            "dueDate": "2021-11-01T10:10:48.072Z",
            "_sum": {
                "balancePaid": 65238.76
            }
        },
    Is there a way to trunc the dates prisma without having to do a raw query? Or is that not possible? I would like to be able to group by date without a specific time getting in the way.
    r
    • 2
    • 1
  • d

    Devi Prasad

    11/24/2021, 8:16 AM
    How can this query be written in prisma?
    Copy code
    `SELECT COUNT(g.id) AS 'total_used', s.`product_name`, s.`current_period_start` AS 'current_period_start', s.`current_period_end` AS 'current_period_end'
    FROM `subscription` s
        JOIN `user` u ON s.`customer_id` = u.`customer_id`
        LEFT JOIN `goat` g ON g.`user_id` = u.`id` AND
              g.`date_created` BETWEEN s.`current_period_start` AND s.`current_period_end`
        WHERE u.`id` = "00000-00000" AND s.`status` = 'ACTIVE'
    r
    • 2
    • 2
  • u

    user

    11/24/2021, 9:41 AM
    Scaling Databases For Serverless World: A Chat With Sugu Sougoumarane - Prisma Serverless Conference

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

    Today, Vitess is the default database for scale at Slack, Roblox, Square, Etsy, GitHub, and many more. But how did it get here? From its creation at YouTube to the database that powers PlanetScale, a serverless database platform, Taylor and Sugu will dive into Vitess' creation, why MySQL, what makes Vitess so powerful, and the different ways it is a great fit for developers building serverless applications. 🗣️Speaker: Sugu Sougoumarane, Taylor Barnett Sugu is also the co-creator of Vitess, which he has been working on since 2010. Prior to Vitess, Sugu worked on scalability at YouTube and was part of PayPal in the early days. His recent interest is in distributed systems and consensus algorithms. Connect with Sugu: https://twitter.com/ssougou Before PlanetScale, Taylor led developer relations at developer-focused startups and was also a full-stack engineer. Taylor is passionate about building great developer experiences, emphasizing empathy within product, documentation, and community-focused projects. Connect with Taylor: https://twitter.com/taylor_atx 📣 Prisma Serverless This talk has been recorded at the Prisma Serverless Conference on November 18, 2021. You can learn more about the Prisma Data Platform here: www.prisma.io/dataplatform
  • u

    user

    11/24/2021, 12:47 PM
    Check our open source website for local groups of women and non-binary people in tech #shorts #wit

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

  • n

    Nathaniel Babalola

    11/24/2021, 1:48 PM
    Hi all, please this issue is still pending. https://prisma.slack.com/archives/CA491RJH0/p1629542896125400?thread_ts=1629542896.125400&cid=CA491RJH0 I would be really grateful if it can be fixed, as at now I have no use for Prisma if it isn't providing types for my models. I just started using it in a new project and still having this same issue. And this is the GitHub issue https://github.com/prisma/prisma/issues/8944#issuecomment-911709218
    r
    • 2
    • 2
  • s

    Simoh 2k

    11/24/2021, 3:10 PM
    Hello everyone, I have a question please. With relationships (eg users / posts) is it possible to get a relationship with a specific role? I would like to get user in model post with role specific (client for exemple) I have this:
    Copy code
    model User {
      id          String   @id @default(uuid())
      username    String
      roleId      String?
      role        Role?    @relation(fields: [roleId], references: [id])
      contact     Contact?
      acceptCGU   Boolean  @default(false)
      opinons Opinion[]
    }
    
    model Role {
      id              String           @id @default(uuid())
      name            String
      description     String
      rolePermissions RolePermission[]
      users           User[]
    }
    
    model Opinion {
      id        String   @id @default(uuid())
      opinionCount     Int?
      descriptionOpinion   String?
      user     User      @relation(fields: [authorId], references: [id])
      authorId String
      createdAt DateTime @default(now())
    }
    r
    • 2
    • 3
  • i

    Irakli Safareli

    11/24/2021, 4:17 PM
    On a server let’s say each request has an id, prisma is set up so that it’s logging everthing, and you want to do so that associate prisma log messages with the request id. I.e. if 2 user sends request at the same time id 1 and 2 and it each request executes 5 prisma queries, logs I want to see
    Copy code
    Request#1 prisma query ...  
    Request#2 prisma query ...  
    Request#1 prisma query ...  
    Request#2 prisma query ...  
    ...
    Is there something that one can do to active this? of course naive approach would be to create multiple prisma clients per request. but if you have 100 requsts and each client creates multiple db connection it’s not good. basically some “soft clone” like function is needed on prisma client
    const softClone = (c: PrismaClient, context: unknown): PrismaClient
    and then in when listening to events on prisma:
    Copy code
    prisma.$on("query", (e) => {
      console.log(e.context, "query", e.query);
    });
    and this softClone should not result in new connections (should use previous prisma client. Any suggestions? is there issue for it? (I’ve created an issue here: https://github.com/prisma/prisma/issues/10425)
    👍 1
    r
    • 2
    • 1
  • d

    Dennis Yurkevich

    11/24/2021, 4:38 PM
    Hi All, does anyone have a good example of how to use Prisma in clean architecture setup? Specifically I am not sure how to make use of the types generated from the
    prisma.schema
    - how would one pull those in as deps to other modules, so as not to keep defining the same types on a bunch of interfaces.
    r
    • 2
    • 4
  • t

    Taras Protchenko

    11/24/2021, 8:10 PM
    Hello, could anyone point me to good DBaas suited for prisma? prisma cool
  • r

    Rykuno

    11/24/2021, 8:42 PM
    @Taras Protchenko I’m using GCP in production and lately PlanetScale in a new project if you wanna check that out
    prisma rainbow 3
    d
    • 2
    • 1
  • r

    Rykuno

    11/24/2021, 8:43 PM
    @Dennis Yurkevich https://github.com/NoQuarterTeam/boilerplate
    d
    • 2
    • 2
  • t

    Tomer Aberbach

    11/25/2021, 2:12 AM
    Hey y'all! I'm wondering if someone could help me figure out how to properly type a function wrapping a prisma call in TypeScript. I have a function that looks something like this:
    Copy code
    export async function getUser(
      request: Request,
      { include }: { include?: Prisma.UserInclude } = {},
    ) {
      const session = await getUserSession(request)
      const userId = session.get(`userId`)
    
      if (!userId || typeof userId !== `string`) {
        return null
      }
    
      return db.user.findUnique({ where: { id: userId }, include })
    }
    Now, no matter what I do, calling
    getUser(request, { include: { classes: true } })
    does not get typed as
    Promise<(User & { classes: Class[] }) | null>
    . It gets typed as
    Promise<(User & {}) | null>
    . I can't figure out how to make it infer the return type properly based on the given
    include
    . Any help would be greatly appreciated!
  • a

    Akshay Kadam (A2K)

    11/25/2021, 9:58 AM
    I am getting
    Property 'settings' is missing in type '{ id: string; name: string; username: string; }' but required in type 'UserCreateInput'.ts(2322)
    but I have set the default values in
    settings
    but it is not optional. How do I fix it? My schema:
    Copy code
    model User {
      id       String  @id @default(cuid())
      username String  @unique
      name     String?
      email    String? @unique
      image    String?
    
      // relations
      settings   Settings @relation(fields: [settingsId], references: [id], onDelete: Cascade)
      teams      Team[]
      settingsId String
    }
    
    model Settings {
      id       String @id @default(cuid())
      timezone String @default("UTC")
    
      // relations
      user User[]
    }
    r
    • 2
    • 3
  • a

    Akshay Kadam (A2K)

    11/25/2021, 10:01 AM
    Why do I have to make it optional even though I have default values set in
    Settings
    ?
    m
    • 2
    • 1
  • a

    Akshay Kadam (A2K)

    11/25/2021, 10:31 AM
    Also, what's the best way to call a nexus mutation from backend? Do I need to directly call it using
    prisma
    or is there a way to call mutation directly? I am doing Oauth so I get the data on the backend only. If I do send it back to client using
    res.send
    & then do mutation
    createUser
    , then its 2 steps. If I don't send it to client but do it on the backend, then I don't use the mutation
    createUser
    but directly do it so its 1 step. What is your recommended approach?
    r
    • 2
    • 12
  • u

    user

    11/25/2021, 11:12 AM
    Building Serverless Apps With Next.Js And Prisma - Hassan El Mghari - Prisma Serverless Conference

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

    Exploring Prisma’s new Data Proxy announcement and how it can be combined with Cloudflare’s Workers platform to build applications that scale globally, without tuning or managing infrastructure. 🗣️Speaker: Hassan El Mghari Hassan is a full-stack software engineer based in Philadelphia. He's passionate about startups in the developer tools space and building interesting side projects. Connect with Hassan: https://twitter.com/Nutlope 📣 Prisma Serverless This talk has been recorded at the Prisma Serverless Conference on November 18, 2021. You can learn more about the Prisma Data Platform here: www.prisma.io/dataplatform
  • m

    Muhammed Kaplan

    11/25/2021, 12:51 PM
    Hello is there any alternatives to Typeorm entity listeners? https://github.com/typeorm/typeorm/blob/master/docs/listeners-and-subscribers.md
    r
    • 2
    • 3
  • a

    Akshay Kadam (A2K)

    11/25/2021, 1:07 PM
    How do I create a related table when the original table is called? Currently, I get this error:
    Copy code
    Error: 
    Invalid `prisma.user.create()` invocation:
      The table `public.Settings` does not exist in the current database.
    My code is simply:
    Copy code
    await prisma.user.create({
    		data: {
    			id,
    			username,
    			name,
    			settings: {
    				connect: {
    					id,
    				},
    			},
    		},
    	})
    I don't think I need to manually create any tables but it does throw an error when the table does not exist. I'm using docker with postgres so not sure if i can create a table in there. how do i solve this?
    r
    m
    • 3
    • 60
  • u

    user

    11/25/2021, 1:17 PM
    Prisma Chats with Emily Morgan

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

    In this video, Marketing Associate Intern Nika Music interviews Emily Morgan, who is a Working Student Engineer at Prisma's Cloud team. The pair talk about university vs. company life balance and positives about working at Prisma. Connect with Emily: GitHub: http://github.com/eemmiillyy Next: 👉 Next video: Prisma Chats w/ Mahmoud Abdelwahab

    https://youtu.be/2beveFa7vXY▾

    👉 Previous video: Prisma Chats w/ Tasin Ishmam

    https://youtu.be/dls7swbphHA▾

    00:25 - Intro 01:05 - Getting started w/ tech world 03:24 - Differences between university and company environments 05:00 - The biggest challenge 07:20 - Favorite part of working at Prisma 09:30 - Most exciting project 10:40 - The most exciting technology 11:50 - Preferred stack 13:15 - Advice for people entering tech world
  • b

    Bamada

    11/25/2021, 2:08 PM
    Hello, Is it possible to write this kind of query with Prisma query builder without using a raw query ?
    SELECT * FROM employees WHERE timesheeting=1 AND year(termination_date)=2021 AND MONTH(termination_date)=10;
    Thks
    r
    • 2
    • 2
  • n

    Nathaniel Babalola

    11/25/2021, 2:37 PM
    Can only year be stored with
    DateTime
    ? If it can't , can I use
    String
    instead and will ordering (asc or desc) work for year stored as
    String
    . ?
    r
    • 2
    • 2
  • h

    henry

    11/26/2021, 9:01 AM
    Hi every one, is there an admin UI i can deploy to production with prisma? i need an admin sytem to manage my content in production
    d
    h
    +2
    • 5
    • 11
  • h

    henry

    11/26/2021, 10:11 AM
    is it possible to use react-admin as admin UI for prisma in production?
  • u

    user

    11/26/2021, 10:19 AM
    Deploy A Serverless Prisma + PlanetScale React TypeScript App To Netlify - Jason Lengstorf

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

    Web devs today have the capability to build truly full-stack apps without needing to become full-stack developers. Huge leaps forward in hosted databases, developer tooling, serverless functions, and deploying to the web have made it possible to tackle hugely ambitious projects as a solo developer or small team in a fraction of the time it used to take. In this talk, Jason Lengstorf will show rather than tell: watch him start from an empty folder and build a database-powered React + TypeScript app using Prisma, PlanetScale, and Netlify Functions, then get the whole thing deployed to production on Netlify — all in about 30 minutes! 🗣️Speaker: Jason Lengstorf Jason Lengstorf is the VP of Developer Experience at Netlify and the host of Learn With Jason, a live-streamed video show where he pairs with people in the community to learn something new in 90 minutes. He’s passionate about building healthy, efficient teams and systems. Connect with Jason: https://twitter.com/jlengstorf 📣 Prisma Serverless This talk has been recorded at the Prisma Serverless Conference on November 18, 2021. You can learn more about the Prisma Data Platform here: www.prisma.io/dataplatform
  • j

    Jorge Whitte

    11/26/2021, 1:36 PM
    hello there, I have a question, regarding type integrity in jsonb (or future mongodb fields) does something like this exist/will exist? so something like this could be done?
    Copy code
    model User{
    name String
    settings: UserSettings
    }
    
    submodel UserSettings {
    smsNotifications Status
    emailNotifications Status
    ... etc
    }
    
    enum Status{
    ON
    OFF
    }
    maybe not the best example, but I think it show the idea, something like this would be like nested type enforcement in models, that doesn't translate into a DB entity
    r
    • 2
    • 2
  • o

    Octavio Augusto Barbosa

    11/26/2021, 3:26 PM
    Hello all! need some help my method below try to access user.company.id, company object has include in findUnique metod in my auth middleware. how i can access this data ?
    Copy code
    async listAccounts(user: Clients): Promise<AccountResponse[]> {
    
            const accounts = await this.prismaService.accounts.findMany({
                where: {
                    company: {
                        id: user.company.id,
                        deletedAt: null
                    }
                }
            })
    
            return plainToClass(AccountResponse, accounts)
        }
    if i try a console.log( user ) i receive all data of clients and company
    r
    • 2
    • 2
1...511512513...637Latest