Prisma find is acting very weird
I have a user table with a relation field of posts.
When I try to use "findFirst" for a user by id, and get the posts using "include: true",
I get returned a user with an empty posts array. The array shouldn't be empty.
I tried "findMany", and what happens is that it returns ALL USERS in the db, which shouldn't happen, cause there's only 1 user who has this unique id, but the users ARE coming back with a none-empty posts array.
WTF?
const getUser = async (id) => {
const user = await prisma.user.findFirst({
where: {
id,
},
include: {
posts: true,
},
});
return user;
};
0 Replies