Kenneth Gitere
06/10/2021, 6:51 AMSascha Ormanns
06/10/2021, 8:16 AMMiddlewares act as query-level lifecycle hooks, which allow you to perform an action before or after a query runs.When running a nested write or update query, is there any chance to get the result of all the queries/statements executed? Or am I on a prisma-client-function-level when in a Middleware and the result is the result returned from that client call? Something like
prisma.user.create({
data: {
email: '<mailto:elsa@prisma.io|elsa@prisma.io>',
name: 'Elsa Prisma',
posts: {
create: [{ title: 'How to make an omelette' }, { title: 'How to eat an omelette' }],
},
},
include: {
posts: true, // Include all posts in the returned object
},
})
Yazid Daoudi
06/10/2021, 8:44 AMjasci
06/10/2021, 8:51 AM// Option 1 - Separate Query
export const Story = {
tags: (_args, parent) =>
db.tag.findMany({ where: { story: { id: parent.id } } })
};
// Option 2 - Fluent API
export const Story = {
tags: (_args, parent) =>
db.story.findUnique({ where: { id: parent.id } }).tags()
};
But also docs states that findUnique
queries are batched and it improves performance, so my thought was to use Fluent api if the separate query uses findMany
like in the example above, but if we were to query single tag
instead of tags
(findUnique
in both separate and fluent api queries) it’s better to use separate query. But regarding this issues people say that 1 query always outperform multiple queries, if that’s the case I don’t see any use cases where Fluent API is preferred.
When would Fluent API be a better choice ?
Thank you.Benjamin Kroeger
06/10/2021, 10:00 AMLevi Lawliet
06/10/2021, 10:24 AMPaul G
06/10/2021, 11:12 AMDev__
06/10/2021, 2:17 PMinclude
but its not working. the relation sort does work at the orderBy
where,
include: {
buyerGroupDescriptions: {
where: {
languageId
},
orderBy: {
name: order // 'asc' or 'desc', not working
}
}
}
orderBy: {} // working
jasci
06/10/2021, 3:55 PM$exists
property from prisma1?drongo
06/10/2021, 4:05 PMIndxgo
06/10/2021, 4:50 PMBenjamin Klotz
06/10/2021, 5:14 PMali
06/10/2021, 5:25 PM// WORKS - (rollback of write2 happens if write1 fails)
const write1 = prisma.user.create()
const write2 = prisma.post.create()
await prisma.$transaction([write1, write2])
// BROKEN? - (write2 is NOT rolled back if write1 fails)
const write1 = prisma.user.create()
const write2 = prisma.post.create()
write2.then(() => console.log('something happened'))
await prisma.$transaction([write1, write2])
Is this behavior expected?kfredericks
06/10/2021, 7:15 PMTim Griffin
06/10/2021, 7:27 PM@db.ByteA
type on one of my fields and save a buffer
to it with length < 8192, the resulting buffer when I request it from the database again is 8192. Larger buffers I've saved and successfully retrieved from the databasejasci
06/10/2021, 7:55 PMPrismaClientType
) ? Also is there some info in the doc about the generated files for prisma client I can read ?Dev__
06/11/2021, 6:42 AMuser
06/11/2021, 9:48 AMWuxxy
06/11/2021, 11:05 AMWuxxy
06/11/2021, 11:06 AMnpx prisma db push
btw to test this - and prisma won't connect when I use server IP when using the client itselfWuxxy
06/11/2021, 11:17 AMWuxxy
06/11/2021, 11:17 AM<username>
was denied access on the database <databasename>.public
Nichita Z
06/11/2021, 11:40 AMNichita Z
06/11/2021, 11:41 AMNic Luciano
06/11/2021, 1:01 PMfilterJson
preview feature to query where a path is undefined
, i get A JSON path cannot be set without a scalar filter.
at runtime, despite the InputJsonValue
type allowing undefined. the json field is nullable, and has a default set to {}
in prisma.
am i doing something wrong? or is support still limited? thank you. 🙂Julian
06/11/2021, 2:18 PMLevi Lawliet
06/11/2021, 3:46 PMIndxgo
06/11/2021, 4:43 PMawait prisma.account
.findFirst({
where: {
id: user.id,
authorization: user.authorization,
},
});
but I can use
await prisma.account
.findMany({
where: {
id: user.id,
authorization: user.authorization,
},
});
If I use the first example I get an error:
Argument where of type AccountWhereUniqueInput needs exactly one argument, but you provided id and authorization. Please choose one. Available args:
Nevermind, the second example was working yesterday night but now both give the error, any help?Indxgo
06/11/2021, 9:26 PMArgument where of type AccountWhereUniqueInput needs exactly one argument, but you provided id and authorization. Please choose one. Available args:
I don't know how to fix itManthan Mallikarjun
06/12/2021, 2:52 AM