You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Hi, I need update a post which connect to a user.
When someone request to update a field in that post, what is the best way to check that is user is the post's owner?
update(user: JWT, postId: number, updatePostDto: UpdatePostDto) {
return this.prm.deal.update({
where: { id:postID, authorId: user.id }, // I have user ID here
data: updateDealDto,
});
I don't really want use updateMany
. It doesn't return updated post.
Hey @IRediTOTO 👋 ,
The easiest way to do this is to update the post through the user.
let result = await prisma.user.update({
where: { id: userId },
data: {
posts: {
update: {
where: { id: postId },
data: { postDTO }
Let me know if that will work for you!
Hey @IRediTOTO 👋 ,
The easiest way to do this is to update the post through the user.
let result = await prisma.user.update({
where: { id: userId },
data: {
posts: {
update: {
where: { id: postId },
data: { postDTO }
Let me know if that will work for you!