#Prisma - Query Relation / Relationship between two tables
9 messages · Page 1 of 1 (latest)
Hi
Can you try with the include keyword please?
try {
const switchData = await db.switch.findUnique({
where: {
id: switchId, // replace switchId with the actual switch id
},
include: {
images: true,
},
});
if (!switchData) {
return <Custom404 />;
}
console.log(switchData.images); // this will log the images belonging to the switch
} catch (error) {
console.log(error);
}