Dog
04/13/2022, 9:00 PMawait prisma.tweet.findMany({
include: {
user: {
select: {
id: true,
displayName: true,
username: true,
},
},
},
});
I basically decide to take all fields from the user, besides the password. Is this the best way to do it? Since I might be using other models that require me to get the user, doing this on every query seems a bit repetitive. I was thinking I could do 2 things:
Have the private info of the user in 1 model and all the public one in another. So the User model would have an id, password and email and the Profile the username, displayName, etc. The second option would be to keep the models as they are and instead just save an object in another file that looks kinda like this
{
id: true,
displayName: true,
//etc
}
and then just put that in every select so that at least, if the user model changes, it updates in all queries that involve the user.Ian Ray
04/13/2022, 9:03 PMIan Ray
04/13/2022, 9:04 PMDog
04/13/2022, 9:04 PMDog
04/13/2022, 9:05 PMIan Ray
04/13/2022, 9:05 PMIan Ray
04/13/2022, 9:05 PMIan Ray
04/13/2022, 9:05 PMDog
04/13/2022, 9:10 PMIan Ray
04/13/2022, 9:14 PMDog
04/13/2022, 9:16 PMAustin
04/13/2022, 9:43 PMDog
04/13/2022, 9:45 PMAustin
04/13/2022, 9:50 PMDog
04/13/2022, 9:55 PMAustin
04/13/2022, 10:00 PMDog
04/13/2022, 10:04 PM