Toggle Upvote
Add or remove a like/upvote on a note. Use thetype parameter to specify whether to add or remove the like.
Headers
Bearer token for authentication
Query Parameters
The ID of the note to like or unlike
Action to perform:
add to like the note, remove to unlikeResponse
Success message indicating like or unlike action
Response Examples
Like AddedThe endpoint uses a many-to-many relationship between users and notes. When you add a like, the current user is connected to the note’s likes relation. When you remove a like, the user is disconnected.
Error Responses
Error message
HTTP status code
Implementation Details
The upvote system uses Prisma’sconnect and disconnect operations on the likes relation:
- Add like: Connects the authenticated user to the note’s
likesarray - Remove like: Disconnects the authenticated user from the note’s
likesarray
- Each note can have multiple users who liked it
- Each user can like multiple notes
- The same user cannot like a note multiple times (enforced by Prisma)