https://www.prisma.io/ logo
Join SlackCommunities
Powered by
# prisma-client
  • g

    Ge Yang

    05/31/2022, 2:18 PM
    Here is a question specific for MongoDB. Does anyone know how to extend a list in MongoDB?
    ✅ 1
  • u

    uzu

    06/02/2022, 3:17 AM
    has anyone experienced problem with
    some
    query with mongodb connector?
    Copy code
    const list = await this.prisma.workspace.findMany({
          where: {
            members: {
              some: {
                user: {
                  uid: uid,
                },
              },
            },
          },
          include: {
            members: true,
          },
        });
        return list;
    returns [] (no data)
    Copy code
    const list = await this.prisma.workspace.findMany({
          where: {
            OR: [
              {
                members: {
                  every: {
                    user: {
                      uid: uid,
                    },
                  },
                },
              },
              {
                members: {
                  some: {
                    user: {
                      uid: uid,
                    },
                  },
                },
              },
            ],
          },
        });
        return list;
    => returns [a, b, c, …]
    👀 1
    a
    • 2
    • 1
  • m

    Mischa

    06/05/2022, 7:35 PM
    any suggestions about what to do with this error? "Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Expired'." I'm using 3.14.0 I increased timeouts and these queries generally take ~500ms though they can take longer under load
    Copy code
    {
          maxWait: 20000, // default: 2000
          timeout: 60000, // default: 5000
        }
    {"is_panic":false,"message":"Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Expired'.","meta":{"error":"Transaction already closed: Transaction is no longer valid. Last state: 'Expired'."},"error_code":"P2028","clientVersion":"3.14.0"}
    👀 1
    ✅ 1
    n
    i
    • 3
    • 16
  • j

    Jeet Mehta

    06/10/2022, 3:58 PM
    👋 Hey folks. Is there anyway I can order the overarching objects by the column in a deeply nested relation? For example, I have a class, which has a service, which has a booking group, which has bookings. I'd like to order the list of classes returned by a
    prisma.class.findMany
    , by the
    booking.startTime
    (see an example in the thread below👇):
    👀 1
    n
    • 2
    • 2
  • k

    Kay Khan

    06/15/2022, 10:06 AM
    I'm really liking the prisma.<model>.create. It's making my life very easy right now with relationships. But i have a question, if for whatever reason the overall object fails to create, what happens to the
    image.connect
    and
    brand_indusry.createMany
    we'd want them to also fail right? I guess its obvious you can't really connect or have a relationship to createMany if nothing is made.
    Copy code
    const newBrand: Prisma.brandCreateInput = {
                id: uuid(),
                name: payload.name,
                website: payload.website,
                slug: payload.slug,
                image: { connect: { id: payload.image_id } },
                brand_industry: { createMany: { data: industries } },
            };
    
            const createBrand = await PrismaService.brand.create({
                data: newBrand,
            });
    ✅ 1
    r
    • 2
    • 2
  • w

    William Harding

    06/17/2022, 4:34 PM
    Feel free to tell me this isn't the place to ask this question. I have been using the "experimental"
    filterJson
    feature to query my Postgres JSONB columns. Does Prisma provide any ability to update JSONB columns (other than wholesale replacement or using
    raw
    execution)?
    ✅ 1
    n
    • 2
    • 2
  • m

    Mitko Tschimev

    06/19/2022, 8:23 PM
    Hi Everyone, I am struggling with my aws lambda deployment with Prisma. Currently I am getting following error on lambda execution:
    Copy code
    {
      "errorType": "TypeError",
      "errorMessage": "collection is not iterable",
      "clientVersion": "3.6.0",
      "stack": [
        "TypeError: collection is not iterable",
        "    at keyBy (/opt/nodejs/node14/node_modules/@prisma/client/runtime/index.js:42314:21)",
        "    at DMMFHelper.getTypeMap (/opt/nodejs/node14/node_modules/@prisma/client/runtime/index.js:42648:17)",
        "    at new DMMFHelper (/opt/nodejs/node14/node_modules/@prisma/client/runtime/index.js:42545:25)",
        "    at new PrismaClient (/opt/nodejs/node14/node_modules/@prisma/client/runtime/index.js:49486:22)",
        "    at Object../apps/tipyourhero-yoga/src/app/context.ts (/var/task/main.js:160:16)",
        "    at __webpack_require__ (/var/task/main.js:880:41)",
        "    at /var/task/main.js:897:19",
        "    at /var/task/main.js:932:3",
        "    at Object.<anonymous> (/var/task/main.js:937:12)",
        "    at Module._compile (internal/modules/cjs/loader.js:1085:14)"
      ]
    }
    Someone has an idea what the problem is / could be?
    Copy code
    @prisma and .prisma
    are deployed as aws lambda layer
    ✅ 1
    r
    • 2
    • 4
  • k

    Kay Khan

    06/20/2022, 10:49 AM
    I'm having an issue with using
    [entity].create()
    and "connect" for relationships.. I have the following input, you can see im attaching 2 relationships when creating this
    brand
    entity. (
    image
    &
    brand_industry
    ). - In the
    brand
    table,
    image
    is nullable:
    Copy code
    `image_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
    Copy code
    const newBrand: Prisma.brandCreateInput = {
                id: brandId,
                name: payload.name,
                website: payload.website,
                slug: payload.slug,
                image: { connect: { id: payload.image_id } },
                brand_industry: { createMany: { data: industries } },
            };
    When i build this object, there is a chance that payload.image_id will be undefined which the prisma client accepts. example:
    Copy code
    {
      id: '9f77cc53-732b-4c1d-bdca-b14f4cbc7643',
      name: 'test',
      website: 'test',
      slug: 'test',
      image: { connect: { id: undefined } },
      brand_industry: { createMany: { data: [Array] } }
    }
    
     const createBrand = await PrismaService.brand.create({
                data: newBrand,
            });
    However the query fails because image_id is undefined then. Kind of wish it would support if its undefined to insert null. WIthout me having to explicitly check. --- looks like i can't set it to null excplicity even if i wanted to because the types don't allign.
    Copy code
    image: { connect: { id: payload.image_id ? payload.image_id : null } },
    Copy code
    Type 'null' is not assignable to type 'string | undefined'.
    Copy code
    export type imageWhereUniqueInput = {
        id?: string
      }
    Seems pretty awkward to me, am i doing something wrong? because i believe now i have to do the check before adding the newBrand.image field
    ✅ 1
    n
    • 2
    • 4
  • c

    Casey Chow

    06/21/2022, 10:34 PM
    Has anyone had issues with Prisma building on the Heroku-22 stack?
    👀 1
    n
    • 2
    • 2
  • f

    Florian Thelliez

    06/22/2022, 2:31 PM
    Hi ! I’m just starting to integrate metrics (pretty much following the example with hotshots in the docs) but my team and I have a quite strong dislike of using any, and I was trying to use the metric types defined in the client but it seems they are not exported. Would this be something that could be changed ? 🙂
    ✅ 1
    a
    a
    m
    • 4
    • 15
  • j

    Jacob Coker-Dukowitz

    06/22/2022, 10:37 PM
    Just curious if soft delete (issue here) is on the roadmap? The docs (as noted by Prisma) are not actually ready for production use, and are just a proof of concept. Following that, the examples given in the docs don't fit many use cases. A short example of use cases unmet by the docs: •
    findMany({ where: some|none|etc })
    , •
    findMany({ where: {}, include: { }
    •
    update({data: { posts: { deleteMany: { } } } })
    •
    update({data: { posts: { updateMany: {  } } } })
    •
    update({data: { posts: { update: { where: {} } } })
    • A longer list can be found here.
    ✅ 1
    v
    n
    • 3
    • 5
  • w

    Wingy

    06/23/2022, 5:22 PM
    prisma.$queryRawUnsafe is returning Numbers for BigInts in my database, is there any way to get bigints from it?
  • w

    Wingy

    06/23/2022, 5:26 PM
    i found improvedQueryRaw
    🚀 1
    👀 1
    ✅ 1
  • m

    Mons Erling Mathiesen

    06/24/2022, 11:55 AM
    Copy code
    model SomeModel {
      id                       String                    @id @default(uuid())
      name                     String
      SomeRelation             SomeRelation?             @relation(fields: [someRelationId], references: [id], onDelete: SetNull)
      someRelationId           String?
    Hi, I was wondering if anyone can assist me with the following: I have a schema (similar to the one above) where the fk to SomeRelation is optional. In my "updateSomeModel" command - I am not allowed to update
    {someRelationId: null}
    even though the field is "nullable". This is problematic due to differentiating between removing an existing value and "not updating" if not set already. Is there a way to update to null on this kind of field?
    ✅ 1
    👀 1
    a
    • 2
    • 4
  • w

    William Harding

    06/25/2022, 4:32 PM
    I am attempting to run an
    executRaw
    query, passing in a list of numbers (
    customerIds
    ) (joined on
    ","
    to create a string). I am getting this error:
    Copy code
    Raw query failed. Code: `08P01`. Message: `db error: ERROR: insufficient data left in message`
    This is the the query that does not work,
    Copy code
    await prisma.$executeRaw`UPDATE "Customer" SET fields = fields || ${fieldUpdates} WHERE ("organizationId" = ${organizationId} AND id IN (${customerIds.join(",")}));`
    It works if I hardcode the values, like this ,
    Copy code
    await prisma.$executeRaw`UPDATE "Customer" SET fields = fields || ${fieldUpdates} WHERE ("organizationId" = ${organizationId} AND id IN (1,2,3)}));`
    Console logging my list out, produces the correct results,
    Copy code
    1,2,3
    I wasn't able to find this as a bug specifically against Prisma, but wanted to check here if it is a known bug, or if there is something I'm doing obviously wrong.
    ✅ 1
    r
    i
    • 3
    • 8
  • v

    Vladislav

    06/26/2022, 2:35 PM
    Hello! I am learning Prisma now. Using it inside Nest.js framework. I want to use PostGIS, but as I see if I use
    Unsupported
    in schema then it is not possible to use
    create
    method. So I am using
    $queryRaw
    . But I can't understand what should I do with
    cuid
    ,
    createdAt
    ,
    updatedAt
    . I should install cuid lib and generate cuid manually or it can be done somehow inside?
    ✅ 1
    n
    • 2
    • 1
  • c

    Casey Chow

    06/27/2022, 5:19 PM
    Question: what’s preferred,
    prisma.$transaction
    or
    Promise.all
    for parallel reads?
    r
    • 2
    • 1
  • a

    akku

    06/28/2022, 3:03 AM
    Hi, I’m using node-cron to clean up all expired
    Invites
    every minute, with each having an
    expiry
    field. How can I use
    prisma.invite.deleteMany
    and select all documents where the
    expiry
    date is in the past?
    ✅ 1
    • 1
    • 2
  • k

    Kay Khan

    06/28/2022, 12:12 PM
    Can anyone take a look at my issue - https://github.com/prisma/prisma/discussions/14034 having a strange behaviour where my query hangs.
  • k

    Kay Khan

    06/28/2022, 12:44 PM
    ^ this problem was solved by setting QUERY_BATCH_SIZE=999 environment variable. But i dont understand why or what consequences setting this value might have else where , can anyone explain?
  • m

    Mischa

    06/28/2022, 11:30 PM
    thanks so much for making the prisma client smaller! i am trying 4.0.0 out at the earliest opportunity
  • m

    Mischa

    06/29/2022, 1:26 AM
    having to add explicit type casts everywhere is a bit painful, i have a lot of hand-written upserts and use UUIDs everywhere
    sadparrot 1
  • o

    OYΞD

    06/29/2022, 11:42 AM
    Hey all - is there a method of keeping all enums from Prisma schema in the output build even if they're unused? I'd prefer defining all my enums in Prisma so I'm not having to do it in multiple places.
    ✅ 1
    a
    m
    • 3
    • 6
  • p

    Pascal Sthamer

    06/30/2022, 11:05 AM
    Is it expected, that Prisma 4 returns a
    Decimal
    for a column that sums up integers when using
    $queryRaw
    ?
  • p

    Pascal Sthamer

    06/30/2022, 11:07 AM
    Sample query:
    Copy code
    SELECT
    SUM(payment.price) AS 'income',
    YEAR(payment.createdAt) AS 'year',
    MONTH(payment.createdAt) AS 'month'
    FROM
    (
    	SELECT price, createdAt
    	FROM pay_pal_payment
    	WHERE status = ${PayPalPaymentStatusEnum.COMPLETED}
    	UNION ALL SELECT price, createdAt
    	FROM paysafecard_payment
    	WHERE status = ${PaysafecardPaymentStatusEnum.SUCCESS}
    	UNION ALL SELECT price, createdAt
    	FROM stripe_payment
    	WHERE status = ${StripePaymentStatusEnum.COMPLETED}
    	ORDER BY createdAt
    ) payment
    GROUP BY year, month
    ORDER BY year ASC, month ASC
    Prisma used to return
    number
    for
    income
    , instead of
    Decimal
    . I read the changes in Prisma 4, about
    $queryRaw
    type mapping, but in this case it seems odd to me, that it returns a
    Decimal
    , because
    price
    is of type
    Int @db.UnsignedMediumInt
    .
    ✅ 1
    a
    • 2
    • 1
  • p

    Pascal Sthamer

    06/30/2022, 11:20 AM
    Also,
    COUNT(IntColumn)
    now returns a
    BigInt
    . Would be great if this could be added to the docs and migration guide (if intended).
  • a

    Andreas Straub

    06/30/2022, 12:25 PM
    Does anybody here using BigInt with Prisma and Postgres DB? How do you handle it. I would like to get a number for the BigInt Postgres field, but it uses the BigInt in generated models. It’s not handy. The problem with Int is the really small max value in Postgres. So right now we are restricted to the +2,147,483,647. Thats not that much. Any advices how to deal with it?
    ✅ 1
    a
    • 2
    • 2
  • k

    Kay Khan

    07/04/2022, 12:47 PM
    Hi friends, i have a unique constraint on my model
    Copy code
    @@unique([address, date], name: "uniq_address_date")
    I am using
    createMany
    to insert many documents. Is it possible that if any one of those documents doesent' satisfy the requirement, it moves onto the next? in other words i dont want it to fail, i want it to continue with the documents that its able to insert I'm using mongodb and this would normally but done my an unordered insert https://www.mongodb.com/docs/manual/reference/method/db.collection.insertMany/#unordered-inserts is something like this possible?
    ✅ 1
    n
    • 2
    • 2
  • m

    Morbus Iff

    07/05/2022, 4:48 PM
    G'day. I'm using typescript script, and defining an event listener for queries as seen here: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#log-a-query-event-to-console. However, TypeScript is complaining "TS7006: Parameter 'event' implicitly has an 'any' type.". According to the Prisma docs, a query event is a QueryEvent type, but I can't figure out how to import that type so that TypeScript knows it exists.
    🚀 1
    • 1
    • 7
  • k

    Kay Khan

    07/07/2022, 1:10 PM
    Im hoping someone can help me with ignoring inserting of duplicates using prisma client with mongodb - https://github.com/prisma/prisma/discussions/14192
    ✅ 1
1...1920212223Latest