Ge Yang
05/31/2022, 2:18 PMuzu
06/02/2022, 3:17 AMsome
query with mongodb connector?
const list = await this.prisma.workspace.findMany({
where: {
members: {
some: {
user: {
uid: uid,
},
},
},
},
include: {
members: true,
},
});
return list;
returns [] (no data)
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, …]Mischa
06/05/2022, 7:35 PM{
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"}
Jeet Mehta
06/10/2022, 3:58 PMprisma.class.findMany
, by the booking.startTime
(see an example in the thread below👇):Kay Khan
06/15/2022, 10:06 AMimage.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.
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,
});
William Harding
06/17/2022, 4:34 PMfilterJson
feature to query my Postgres JSONB columns. Does Prisma provide any ability to update JSONB columns (other than wholesale replacement or using raw
execution)?Mitko Tschimev
06/19/2022, 8:23 PM{
"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?
@prisma and .prisma
are deployed as aws lambda layerKay Khan
06/20/2022, 10:49 AM[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:
`image_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
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:
{
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.
image: { connect: { id: payload.image_id ? payload.image_id : null } },
Type 'null' is not assignable to type 'string | undefined'.
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 fieldCasey Chow
06/21/2022, 10:34 PMFlorian Thelliez
06/22/2022, 2:31 PMJacob Coker-Dukowitz
06/22/2022, 10:37 PMfindMany({ 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.Wingy
06/23/2022, 5:22 PMWingy
06/23/2022, 5:26 PMMons Erling Mathiesen
06/24/2022, 11:55 AMmodel 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?William Harding
06/25/2022, 4:32 PMexecutRaw
query, passing in a list of numbers (customerIds
) (joined on ","
to create a string). I am getting this error:
Raw query failed. Code: `08P01`. Message: `db error: ERROR: insufficient data left in message`
This is the the query that does not work,
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 ,
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,
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.Vladislav
06/26/2022, 2:35 PMUnsupported
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?Casey Chow
06/27/2022, 5:19 PMprisma.$transaction
or Promise.all
for parallel reads?akku
06/28/2022, 3:03 AMInvites
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?Kay Khan
06/28/2022, 12:12 PMKay Khan
06/28/2022, 12:44 PMMischa
06/28/2022, 11:30 PMMischa
06/29/2022, 1:26 AMOYΞD
06/29/2022, 11:42 AMPascal Sthamer
06/30/2022, 11:05 AMDecimal
for a column that sums up integers when using $queryRaw
?Pascal Sthamer
06/30/2022, 11:07 AMSELECT
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
.Pascal Sthamer
06/30/2022, 11:20 AMCOUNT(IntColumn)
now returns a BigInt
. Would be great if this could be added to the docs and migration guide (if intended).Andreas Straub
06/30/2022, 12:25 PMKay Khan
07/04/2022, 12:47 PM@@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?Morbus Iff
07/05/2022, 4:48 PMKay Khan
07/07/2022, 1:10 PM