Prisa Query doesn´t find the data in my DB

I have this Schema
model CapitalRaids {
id Int @id @default(autoincrement())
clanTag String
clanName String
clan Clan @relation(fields: [clanTag], references: [clanTag])

seasonYear Int
seasonMonth Int

capitalTotalLoot Int
raidsCompleted Int
totalAttacks Int
enemyDistrictsDestroyed Int
offensiveReward Int
defensiveReward Int
totalRaids Int

raids CapitalRaid[] // Relation till array av CapitalRaid

@@unique([clanTag, seasonYear, seasonMonth])
@@map("CapitalRaids")
}
model CapitalRaids {
id Int @id @default(autoincrement())
clanTag String
clanName String
clan Clan @relation(fields: [clanTag], references: [clanTag])

seasonYear Int
seasonMonth Int

capitalTotalLoot Int
raidsCompleted Int
totalAttacks Int
enemyDistrictsDestroyed Int
offensiveReward Int
defensiveReward Int
totalRaids Int

raids CapitalRaid[] // Relation till array av CapitalRaid

@@unique([clanTag, seasonYear, seasonMonth])
@@map("CapitalRaids")
}
I use this query
export async function doesCapitalRaidsExist_clashyClash(clanTag: string, month: number, year: number) {
const foundClan = await prisma.capitalRaids.findFirst({
where: {
clanTag: clanTag,
seasonMonth: month,
seasonYear: year,
},
});
return !!foundClan; // return boolean
}
export async function doesCapitalRaidsExist_clashyClash(clanTag: string, month: number, year: number) {
const foundClan = await prisma.capitalRaids.findFirst({
where: {
clanTag: clanTag,
seasonMonth: month,
seasonYear: year,
},
});
return !!foundClan; // return boolean
}
always get false as a return. Even when the data is in the DB. I have even try this query:
export async function doesCapitalRaidsExist_clashyClash(clanTag: string, month: number, year: number) {
const foundClan = await prisma.capitalRaids.findUnique({
where: {
clanTag_seasonYear_seasonMonth: {
clanTag: clanTag,
seasonMonth: month,
seasonYear: year,
},
},
});
return foundClan;
}
export async function doesCapitalRaidsExist_clashyClash(clanTag: string, month: number, year: number) {
const foundClan = await prisma.capitalRaids.findUnique({
where: {
clanTag_seasonYear_seasonMonth: {
clanTag: clanTag,
seasonMonth: month,
seasonYear: year,
},
},
});
return foundClan;
}
but i get null in retyrn. And i know I have the data in my DB Can anyone suggest why this isnt working? My understanding: @@unique([clanTag, seasonYear, seasonMonth]) means that the group is a unique id. The combination of the data on the keys is what make the row unique. if I have the following row in my table with the following data: clanTag: hippa6 seasonYear: 2024 seasonMonth: 06 And I want to add a new row with the following data: clanTag: hippa6 seasonYear: 2024 seasonMonth: 05 <-- It would work becuase it has 05 and not 06.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server