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

    user

    07/20/2022, 9:53 AM
    👉 Prisma Meetup: CockroachDB Edition - Sid Dange - CockroachDB with Prisma at Vista --

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

    -- ◭ In this talk, you’ll hear firsthand from Sid Dange about how Vista used CockroachDB and Prisma to build and expand their end-to-end solution for role-based access across customer groups. ◭ Sid is a Co-Founder, and CTO at Vista. He was previously an infra/platform engineer at Uber ATG and OpenGov, after graduating UC Berkeley in 2017. Native to the bay area, and now a transplant in LA, he enjoys surfing and building furniture! ◭ Connect with Sid: https://twitter.com/siddange ◭ Join our Prisma Meetup group here: https://www.meetup.com/Berlin-Prisma-Meetup/
    prisma rainbow 3
    🙌 2
  • e

    Eric Kreis

    07/20/2022, 5:19 PM
    [ Prisma Client ] - Binary Targets
    ✅ 1
    a
    • 2
    • 17
  • b

    Ben Ezard

    07/21/2022, 12:48 AM
    prisma db push
    works for MongoDB, but is there a way to prevent it from making breaking changes? (e.g. deleting fields, changing the type of fields, etc) Given that Prisma MIgrate doesn't currently support MongoDB, I'm trying to figure out a good way of replicating the way that migrations work for relational DBs
    ✅ 1
    n
    • 2
    • 3
  • i

    Ishan Chhabra

    07/21/2022, 6:26 AM
    I have been using Apollo Server + Prisma. I was wondering if there is a better way of doing the following. —— Gist: how can I cleanly
    {include: true}
    a relation in prisma only when that field is asked in GraphQL query? Say I have a Book table and an Author table. Book and Author are related. I have a GQL Query
    Copy code
    books {
      name
      author {
        name
      }
    }
    This resolves with
    const books = await prisma.book.findMany({include: {author: true}})
    . What if I did not ask for the author? Although Graphql wont send it to client, I would like to avoid that unnecessary join on orm level. I can use the info param of resolver function to see if that field was asked and conditionally use include in prisma but that is not scalable and kills the dx. I thought if resolver chains could help. But am not sure how to go about it. Any help is much appreciated. Thank you!
    ✅ 1
    j
    n
    • 3
    • 11
  • k

    konsta

    07/21/2022, 8:02 AM
    Hello, is there a way to rename grouped column name:
    Copy code
    const { field } = params
    const { priority, status } = query
    
    const groups = await db.issue.groupBy({
    	where: {
    		priority: {
    			in: priority,
    		},
    		status: {
    			in: status,
    		},
    	},
    	by: [field],
    	_count: true,
    	orderBy: {
    		[field]: 'desc',
    	},
    })
    return groups
    returns
    Copy code
    [
    	{
    		"_count": 338,
    		"status": "open"
    	},
    	{
    		"_count": 312,
    		"status": "in review"
    	},
    	{
    		"_count": 359,
    		"status": "in progress"
    	},
    	{
    		"_count": 314,
    		"status": "done"
    	},
    	{
    		"_count": 366,
    		"status": "canceled"
    	},
    	{
    		"_count": 329,
    		"status": null
    	}
    ]
    let's say to something generic like "status" -> "group"?
    ✅ 1
    n
    l
    • 3
    • 4
  • s

    shahrukh ahmed

    07/21/2022, 11:56 AM
    With pagination, is there a way to check if there's a next page or a previous page, given the point in pagination?
    ✅ 1
    f
    a
    • 3
    • 5
  • b

    Benjamin FROLICHER

    07/21/2022, 2:01 PM
    Hi I'm new to prisma and i'm blocking on seeding my database. Injecting simple data works perfectly but when model became more complicated with foreign keys, Prisma does not agree How do you seed your db with auto incremented foreign keys ?, and same question with many-to-many releation ?
    👀 1
    a
    • 2
    • 4
  • a

    Ant Somers

    07/21/2022, 4:37 PM
    Hello. I have explicit m2m as below. Is there a way to make
    companyId
    of
    @@id([jobId, productId, companyId])
    Copy code
    /// Intermediary between Job and Product
    model Freight {
      tonnage   Float?
      amount    Int?
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
      job       Job      @relation(fields: [jobId], references: [id], onDelete: Cascade)
      jobId     String
      product   Product  @relation(fields: [productId], references: [id], onDelete: Cascade)
      productId String
      reciever  Company? @relation(fields: [companyId], references: [id], onDelete: Cascade)
      companyId String
      pieces    Piece[]
    
      @@id([jobId, productId, companyId])
    }
    
    model Piece {
      id               String        @id @default(cuid())
      number           Int
      time             DateTime      @default(now())
      createdAt        DateTime      @default(now())
      updatedAt        DateTime      @updatedAt
      freight          Freight       @relation(fields: [freightJobId, freightProductId, freightCompanyId], references: [jobId, productId, companyId], onDelete: Cascade)
      freightJobId     String
      freightProductId String
      freightCompanyId String
      damages          PieceDamage[]
    }
    👀 1
    a
    v
    • 3
    • 2
  • m

    Michael Jay

    07/21/2022, 5:10 PM
    Can someone give me a quick rundown (or just a point to the docs) of where
    XUncheckedWithoutYInput
    is coming from, where X and Y are models, Y hasMany X? What does "Unchecked" mean here? I see there's a XOR here:
    XOR<Enumberable<XWithoutYInput>, Enumerable<XUncheckedWithoutYInput>>
    Is the "Unchecked" version some sort of default, because when I explore the client file, it lands me on the Unchecked flavor. I would assume maybe unchecked doesn't do type-checking, but it seems like the type definitions are exactly the same.
    ✅ 1
    a
    • 2
    • 2
  • v

    Vinicius Carvalho

    07/21/2022, 10:10 PM
    hi ... how do I turn this here into a code in prism.client ??? `return await this.prismaService.$queryRaw``
    SELECT date(extract_created_at)
    FROM payment_gateway_extracts
    WHERE client_id = ${clientId}
    GROUP BY date(extract_created_at)
    ORDER BY date(extract_created_at) DESC
    OFFSET ${skip}
    LIMIT ${take}
    ``;`
    👀 1
    j
    n
    • 3
    • 9
  • v

    Vivek Poddar

    07/22/2022, 7:41 AM
    Hi team, I am looking for a real world example where I can have the ability to give optional filers and order by with pagination
    👀 1
    a
    v
    • 3
    • 5
  • v

    Vivek Poddar

    07/22/2022, 7:42 AM
    right now I am doing something like:
    Copy code
    export async function getProducts({
      filters,
      page,
      limit,
      orderBy = { Name: "asc" },
      searchTerm = "",
    }: {
      filters: string[];
      page: number;
      limit: number;
      orderBy?: Record<string, string>;
      searchTerm: string;
    }): Promise<
      Prisma.ProductGetPayload<{
        include: { Category: true };
      }>[]
    > {
      const { skip, take } = getItemsPaginated({ page, limit });
      const prismaDBFilters = filters.map((filter) => ({
        Name: { equals: filter },
      }));
      if (prismaDBFilters.length) {
        return await prisma.product.findMany({
          orderBy,
          skip,
          take,
          where: {
            Name: {
              contains: searchTerm,
            },
            Category: {
              OR: prismaDBFilters,
            },
          },
          include: {
            Category: true,
          },
        });
      } else {
        return await prisma.product.findMany({
          orderBy,
          skip,
          take,
          where: {
            Name: {
              contains: searchTerm,
            },
          },
          include: {
            Category: true,
          },
        });
      }
    }
  • s

    Steven Kuck

    07/22/2022, 4:34 PM
    My team has recently run into https://github.com/prisma/prisma/issues/5006 Is there a place to discuss prisma-engine and possible contributions to the code?
    ✅ 1
    n
    • 2
    • 8
  • b

    Ben Liger

    07/22/2022, 5:10 PM
    Hi there, would be great if someone could answery questions here :) https://github.com/prisma/prisma/discussions/14409
    l
    • 2
    • 1
  • f

    Felipe Paz

    07/22/2022, 6:23 PM
    Hey guys, how's it going? I'd like some help from you. I have this type
    Copy code
    type UserIntensitySetting {
      id: UUID! @id
      category: WorkoutCategory!
      historicalIntensitySettings: [HistoricalIntensitySetting!]! @relation(onDelete: CASCADE)
      user: User!
      createdAt: DateTime! @createdAt
    }
    So, I can do this
    Copy code
    ... await context.prisma.userIntensitySetting({ id: 'asdf-basdf-waaa-234' });
    The problem is I'd like to do this query
    Copy code
    ... await context.prisma.userIntensitySetting({ category: 'strength' });
    But I got an error saying this field is not in the schema. My question is: how could I do this query and use other fields beside the id field?
    👀 1
    a
    n
    • 3
    • 6
  • f

    Felipe Beiger

    07/22/2022, 7:02 PM
    Hey, what's up? I'm new to Prisma, and in my project I'm trying to work with MongoDB as my provider. I had no problems to get all up and running using Mongo's Atlas cloud platform, but I couldn't do the same with a local instance of MongoDB, long history short, I couldn't figure out how to properly configure everything mannualy. If somebody here have any resources over this topic, or can help me with it, I would apreciate a lot 😁.
    ✅ 1
    a
    s
    • 3
    • 3
  • s

    shahrukh ahmed

    07/23/2022, 12:15 PM
    Can we have the horizontal scrollbar back for Prisma Studio, please? 🙃
    ✅ 1
    n
    • 2
    • 1
  • v

    Vivek Poddar

    07/23/2022, 1:42 PM
    I getting an error like:
    Copy code
    The column `(not available)` does not exist in the current database.
    👀 1
    n
    v
    • 3
    • 6
  • v

    Vivek Poddar

    07/23/2022, 1:42 PM
    would like to have more information
  • t

    theory Georgiou

    07/23/2022, 6:39 PM
    Hello, been using prisma in a few projects and love it. However I am very disappointed I ran into an issue that makes prisma unstable and unfit for production envornment and I can no longer trust it on projects as it will break and not allow updates to the databse. Everything was going fine until updating prisma to 4.1.0, then trying to run the npx primsa migrate dev command after a very minor scheme update. there was an error saying prisma@latest was not installed or could not be found. I attempted to toruble shoot this without having to reset all the data in my database but found that to be impossible. No matter what the case prisma always required complete data reset.
    👀 1
    a
    • 2
    • 2
  • t

    theory Georgiou

    07/23/2022, 6:40 PM
    there needs to be a way to reset migration without wiping the database of data.
  • t

    theory Georgiou

    07/23/2022, 6:40 PM
    for when you have bugs between your updates
  • t

    theory Georgiou

    07/23/2022, 6:41 PM
    I'd love to come back to prisma one day, in theory it's the perfect solution for my preferred way of managing databases. but Can't use a library that will break and wipe my database on a supposed "stable" release
    👋 2
    d
    • 2
    • 1
  • a

    Austin

    07/24/2022, 11:45 AM
    is it possible to connect your own database adapter to prisma? I’m having trouble finding documentation about how providers are used/constructed. I’m keen on the idea of exploring a sql-sandbox provider as a way to build a more robust transaction-rollback database testing suite. Any recommended resources on where to get started learning more about that?
    ✅ 1
    n
    • 2
    • 5
  • j

    Jannik Köster

    07/24/2022, 7:20 PM
    Type error: Property 'category' does not exist on type 'PrismaClient<PrismaClientOptions, never, RejectOnNotFound | RejectPerOperation | undefined>'.
    ✅ 1
    n
    • 2
    • 2
  • j

    Jannik Köster

    07/24/2022, 7:20 PM
    Hello guys, as soon as i deploy to vercel im getting this error. everything works in development. im using the same database for deployment and production. I dont get it. Can someone tell me what im missing?
    ✅ 1
  • j

    Jannik Köster

    07/24/2022, 7:21 PM
    nvm, caching error from vercel
  • l

    Lloyd Richards

    07/24/2022, 8:00 PM
    hey everyone! Hope you had a lovely weekend. Does anyone know a way to query for model 1 before a timestamp up to another timestamp? My example is for IoT states which are sent to a large table and i would like to get the states between two dates, but since the timestamps are only for the start of the state, i end up always loosing the first state. I have a weird workaround like this:
    Copy code
    const after = prisma.deviceEvent
              .findMany({
                where: {
                  device_id: device_id || undefined,
                  timestamp: {
                    gte: args.start_date || undefined,
                    lt: args.end_date || undefined,
                  },
                },
              })
    
    const before = prisma.deviceEvent
              .findFirst({
                where: {
                  device_id: device_id || undefined,
                  timestamp: {
                    lte: args.start_date || undefined,
                  },
                },
              })
    
    return [before, ...after];
    but this doesnt feel very elegant and was hoping to find some
    before
    or
    after
    param i could use in prisma. Any suggestions?
    ✅ 1
    n
    • 2
    • 2
  • a

    Adrian

    07/25/2022, 12:26 PM
    Is there any way to use decimal in schema.prisma without using DecimalJS? I created this issue a while ago https://github.com/prisma/prisma/issues/13451
    ✅ 1
    a
    a
    • 3
    • 2
  • a

    Adrian

    07/25/2022, 12:27 PM
    I can't get my open-api SDK right because of incompatible types. My API is return a string not a Decimal
1...599600601...637Latest