SKhan
09/22/2021, 4:02 AMconst teamMsgs = await db.changeLog.findMany({
where: {
AND: [
{
teamId: teamData?.teamId,
},
{
OR: [
{
NOT: {
teamMessageId: null,
},
},
{
NOT: {
commentId: null,
},
},
],
},
],
},
select: {
...
Ryan
09/22/2021, 6:12 AMOR: [
{ teamMessageId: { not: null } },
{ commentId: { not: null } },
]
SKhan
09/22/2021, 7:42 AMAND: [
{
teamId: teamData?.teamId,
},
{
OR: [
{ teamMessageId: { not: null, },},
{commentId: { not: null, },
},
]
}
],
},
select : {...
SKhan
09/22/2021, 7:49 AMRyan
09/22/2021, 7:55 AMteamMessageId is not null
then it’s the correct one and the data would not be present that needs to be matched.SKhan
09/22/2021, 9:12 AMSELECT FROM "ChangeLog" WHERE ("ChangeLog"."teamMessageId" IS NOT NULL OR "ChangeLog"."commentId" IS NOT NULL) ORDER BY "ChangeLog"."timeStamp" ASC OFFSET $1 [0]
there is no teamId
in the query aboveSKhan
09/22/2021, 10:26 AMawait db.changeLog.findMany({
where: {
AND: [
{
OR: [{ teamMessageId: { not: null } }, { commentId: { not: null } }],
},
{ teamId: teamData?.teamId,},
],
},
(I pushed the teamId condition below the OR. However, that did not work either. The SQL query is still without teamId condition.
• I upgraded to Prisma@3.0.2, however, am still getting the same resultsRyan
09/22/2021, 10:31 AMteamData?.teamId
is returning undefined
. Anything undefined in Prisma means that the condition will not be considered at all.SKhan
09/22/2021, 10:52 AM