b0ngl0rd
b0ngl0rd
PPrisma
Created by b0ngl0rd on 10/17/2024 in #help-and-questions
Argument `where` of type *WhereUniqueInput needs at least one of `id` arguments.
looks like prisma only reports the first in the batch as the problem, when it could be any of them.
12 replies
PPrisma
Created by b0ngl0rd on 10/17/2024 in #help-and-questions
Argument `where` of type *WhereUniqueInput needs at least one of `id` arguments.
prisma:client prisma.dealer.update({
where: {
id: undefined
},
data: {
breakStartTime: new Date("2024-10-18T21:00:01.763Z"),
table: {
disconnect: true
}
}
})
prisma:client prisma.dealer.update({
where: {
id: undefined
},
data: {
breakStartTime: new Date("2024-10-18T21:00:01.763Z"),
table: {
disconnect: true
}
}
})
is the cause. so this is because i misunderstood the docs or something on how to make a query optional.
12 replies
PPrisma
Created by b0ngl0rd on 10/17/2024 in #help-and-questions
Argument `where` of type *WhereUniqueInput needs at least one of `id` arguments.
after digging on how to enable debug logs for prisma, i found out that it was another query responsible.
12 replies
PPrisma
Created by b0ngl0rd on 10/17/2024 in #help-and-questions
Argument `where` of type *WhereUniqueInput needs at least one of `id` arguments.
so it turns out that prisma won't always return the correct query responsible for throwing an error when processing a transaction.
12 replies
PPrisma
Created by b0ngl0rd on 10/17/2024 in #help-and-questions
Argument `where` of type *WhereUniqueInput needs at least one of `id` arguments.
model Dealer {
id Int @id @default(autoincrement())
name String
gamesKnown Game[]
startTime DateTime
breakStartTime DateTime?
table Table? @relation("dealer")
goingTo Table? @relation("relief")
}
model Dealer {
id Int @id @default(autoincrement())
name String
gamesKnown Game[]
startTime DateTime
breakStartTime DateTime?
table Table? @relation("dealer")
goingTo Table? @relation("relief")
}
model Table {
id Int @id @default(autoincrement())
tableNum Int
game Game @relation(fields: [gameId], references: [id])
gameId Int
dealer Dealer? @relation("dealer", fields: [dealerId], references: [id])
dealerId Int? @unique
dealerStartTime DateTime?
relief Dealer? @relation("relief", fields: [reliefId], references: [id])
reliefId Int? @unique
}
model Table {
id Int @id @default(autoincrement())
tableNum Int
game Game @relation(fields: [gameId], references: [id])
gameId Int
dealer Dealer? @relation("dealer", fields: [dealerId], references: [id])
dealerId Int? @unique
dealerStartTime DateTime?
relief Dealer? @relation("relief", fields: [reliefId], references: [id])
reliefId Int? @unique
}
12 replies
PPrisma
Created by b0ngl0rd on 10/17/2024 in #help-and-questions
Argument `where` of type *WhereUniqueInput needs at least one of `id` arguments.
It's the object inside that array, yes. In the bigger picture, this is a piece of a transaction, hence the array. However, the error points to this exact query.
12 replies
PPrisma
Created by b0ngl0rd on 10/17/2024 in #help-and-questions
Argument `where` of type *WhereUniqueInput needs at least one of `id` arguments.
No description
12 replies
TtRPC
Created by Weldawadyathink on 10/4/2024 in #❓-help
Error with AppRouter type mismatch in Deno
It might be typescript related. I'm also having tons of issues with autocomplete in a monorepo with a NextJS+tRPC project and api client project. I'm instead getting either "any" type or a typescript property overwrite error depending on whether I import directly or through a barrel file.
8 replies
PPrisma
Created by b0ngl0rd on 8/17/2024 in #help-and-questions
Implicit many-to-many problems
Turns out, for whatever reason the input to createMany doesn't include relational fields? I'm too busy to look into it further, but here is the updated code which succeeded for anyone that might be wondering:
const dealers = () => {
const dealers: Prisma.DealerCreateInput[] = [];

for (let i = 0; i < 10; i++) {
const connect: Prisma.GameWhereUniqueInput[] = f.helpers
.arrayElements(games, { min: 1, max: 3 })
.map((game) => ({ id: game.id }));
dealers.push({
name: f.person.fullName(),
startTime: new Date(
date.setHours(f.number.int({ min: 0, max: 23 }), 0, 0, 0)
),
gamesKnown: {
connect,
},
});
}
return dealers;
};

const data = dealers();
await prisma.$transaction(
data.map((dealer) => prisma.dealer.create({ data: dealer })) // pass an array of queries, instead of one many query.
);
const dealers = () => {
const dealers: Prisma.DealerCreateInput[] = [];

for (let i = 0; i < 10; i++) {
const connect: Prisma.GameWhereUniqueInput[] = f.helpers
.arrayElements(games, { min: 1, max: 3 })
.map((game) => ({ id: game.id }));
dealers.push({
name: f.person.fullName(),
startTime: new Date(
date.setHours(f.number.int({ min: 0, max: 23 }), 0, 0, 0)
),
gamesKnown: {
connect,
},
});
}
return dealers;
};

const data = dealers();
await prisma.$transaction(
data.map((dealer) => prisma.dealer.create({ data: dealer })) // pass an array of queries, instead of one many query.
);
4 replies