Pranav Sathyanarayanan
06/02/2021, 7:42 PMqueryRaw in Prisma 2.23.0?
await prisma.$queryRaw(`
SELECT c."uuid", c."createdAt"
FROM "EmploymentRecord" AS er
JOIN "User" AS u ON (u."uuid" = er."userUuid")
JOIN "Company" AS c ON (c."uuid" = er."companyUuid")
WHERE er."endDate" IS NULL
AND LOWER(u."email") IN (${Array.from(prodUserEmails)
.map((email) => `'${email}'`)
.join(', ')})
GROUP BY c."uuid", c."createdAt"
ORDER BY c."createdAt" ASC;
`);
The query above works perfectly and returns my several hundred rows, but:
await prisma.$queryRaw`
SELECT c."uuid", c."createdAt"
FROM "EmploymentRecord" AS er
JOIN "User" AS u ON (u."uuid" = er."userUuid")
JOIN "Company" AS c ON (c."uuid" = er."companyUuid")
WHERE er."endDate" IS NULL
AND LOWER(u."email") IN (${Array.from(prodUserEmails)
.map((email) => `'${email}'`)
.join(', ')})
GROUP BY c."uuid", c."createdAt"
ORDER BY c."createdAt" ASC;
`;
Does not. I know I am manually string quoting my values, but not sure how else to perform an IN with queryRawJohn Egan
06/02/2021, 8:31 PMprisma migrate deploy with a Vercel deployment workflow + digital ocean pooled postgresql db & pgbouncer and can't quite figure out the right way to define a different DATABASE_URL to run during build time vs. runtime (in order to point to the non-pgbouncer URL during migrations at build time).
It looks like Vercel exposes the "CI" env variable during build time which I thought would be helpful but is there a way to include a conditional in the schema.prisma file to react to this? Something like the following (which does not work for obvious reasons)?
datasource db {
provider = "postgresql"
url = env("CI") ? env("DATABASE_URL_NOPGBOUNCER") : env("DATABASE_URL")
}
Thanks!Mattia Romeo
06/02/2021, 9:33 PMmigrate deploy needs to point to an actual database instance but why does migrate dev? To do its work it just needs the schema and the list of previous migrations, no?YErii
06/03/2021, 8:11 AMnotIn operator?
for example we have 5 users, 3 is in the condition and 2 is not. if we execute
prisma.user.findMany({where: {notIn: [...]}}) will return 7 result.
the above is to clarify the problem and the real count may be 5000 items in notIn clause which returns wrong result.
But prisma.user.count(...) and prisma.user.findMany({where: {NOT: {in: []}}}) are okYErii
06/03/2021, 8:34 AMnotIn clause to 5000 per chunk and merge each result which result in the wrong total count resultsYErii
06/03/2021, 8:36 AMIn cluase, the merge of each chunk is ok. And for {NOT: { in: [] } } it will not split params to chunks. So both of this situation are ok.YErii
06/03/2021, 8:45 AMconst v = await prisma.user.findMany({
where: {id: {notIn: Array.from({length: 6000}, (v, idx) => idx.toString())}}
})
const total = await prisma.user.findMany({
where: {}
})
console.log(v.length, total)
this should reproduct the problem.Swapnull
06/03/2021, 9:39 AMconst lastLesson = await db.lesson.findFirst({ where: { date: { gt: new Date() } }});
but I have a field called lesson.duration. So I would ideally want to do only get it if the duration has passed, maybe something like this
const lastLesson = await db.lesson.findFirst({ where: { date: { gt: addMinutes(new Date(),
this.duration) } }});
basically can I get the where to know context about the current row somehow so it can know what the duration is while checking, rather than having to loop?
Is this possible?manuel
06/03/2021, 10:09 AMPatrick
06/03/2021, 10:54 AMDan Shapir
06/03/2021, 11:15 AMSwapnull
06/03/2021, 3:05 PMJared Salzano
06/03/2021, 7:16 PMJose Maria CL
06/03/2021, 7:41 PMBojan Å ernek
06/03/2021, 8:38 PMaspect
06/03/2021, 9:34 PMhttps://i.imgur.com/5nguZhE.pngā¾
Dan Shapir
06/03/2021, 10:03 PMjasci
06/04/2021, 10:06 AMnexus-plugin-prisma and nexus-prisma. As I understood Iād better use nexus-plugin-prisma in production, but wanted to ask how hard will it be to then replace it with the new nexus-prisma when itās production ready ? I mean it seems like nexus-plugin-prisma is gonna be deprecated soon, but nexus-prisma is not ready, maybe itās safer to wait until itās ready and for now use SDL first ?
Thank you.Dev__
06/04/2021, 1:10 PMTharshan
06/04/2021, 2:07 PMNimish Gupta
06/04/2021, 6:27 PM// Node js
// Fetched a connection from pool. --> (1)
const firstQuery = await prisma.model.find();
// Fetched a connection from pool. --> (2)
const secondQuery = await prisma.model.find();
So 1 and 2 statements are logged while calling these queries. Can you explain why second statement is logged? Prisma should use the same connection (connection used for performing first query), right?Nimish Gupta
06/04/2021, 6:28 PMCarlos Moreira
06/04/2021, 10:43 PMesau
06/05/2021, 12:48 AMThe change you are trying to make would violate the required relation...
This may be a complete oversight but thanks in advance for the help! šEric Martinez
06/05/2021, 1:42 AMEric Martinez
06/05/2021, 1:42 AMEric Martinez
06/05/2021, 1:43 AMconst test = await this.prisma.proyecto.findMany({
include: {
owner: {
where: {
nombre: {
contains: 'asd'
}
}
}
}
});
Unknown arg `where` in include.owner.where for type Owner. Did you mean `select`? Available args:
type owner {
}amaraa
06/05/2021, 4:18 AMMohit Gupta
06/05/2021, 7:51 AMŠ¢Š¾ŃŠµ
06/05/2021, 11:19 AMconst User = objectType({
name: 'User',
definition(t) {
<http://t.nonNull.int|t.nonNull.int>('id')
t.string('name')
t.nonNull.string('email')
t.nonNull.list.nonNull.field('posts', {
type: 'Post',
resolve: (parent, _, context) => {
return context.prisma.user
.findUnique({
where: { id: parent.id || undefined },
})
.aggregate(*some logic)
},
})
},
})