Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7654895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:22:24+00:00 2026-05-31T12:22:24+00:00

The verbs are pretty straightforward for CRUD actions. What would be the right HTTP

  • 0

The verbs are pretty straightforward for CRUD actions.

What would be the right HTTP verb for only performing an action, something
like an upvote?

Maybe this speaks more to data modeling? Is an upvote a resource or just an attribute? I’m unsure about that. Let’s say it does modify the resource directly by calling #upvote on the model.

For example, if I upvote a question here on SO, what verb should be ideally used for that action? I am modifying the resource in a partial manner (PATCH?), but at the same time, I don’t want to specify the new value as I could encounter concurrency issues, so this would best be managed by the database. In other words, we want to ask the server to perform an incremental action on a resource. Is that covered by PATCH?

I’ve seen a similar question asked there, but their case pointed to the creation of a new resource by viewing the job request as an object to be created. Are we in the same case here?

If the PATCH method really would be appropriate, what would it contain?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:22:25+00:00Added an answer on May 31, 2026 at 12:22 pm

    Maybe this speaks more to data modeling? Is an upvote a resource or just an attribute?

    Modelling impacts Implementation

    We are usually modelling something from the real world and our choice of representation will seriously affect the capabilities of the developed system. We could implement our vote in two ways: as an attribute on the thing being voted on or as an entity in its own right. The choice will affect how easily we can implement desired features.

    Two possible implementations …

    1. Votes as entities

    I would model this with a resource which modelled the relationship between the voter and the thing being voted on. Why?

    The vote has state:

    • what was being voted on
    • who voted,
    • when did they vote.
    • was it an up vote or a down vote (you mentioned SO as an example so I include that possibility here)

    It is a resource in its own right with interesting behaviour around the votes

    • maintain a correct count of the votes
    • prevent multiple up votes / down votes

    It can be modelled easily with REST.

    I can POST/PUT a new vote, DELETE a previous vote, check my votes with a qualified GET.

    The system can ensure that I only vote once – something which would not be easy to do if a simple counter was being maintained.

    2. Votes as an attribute

    In this implementation, we model the vote as a counter. In this case we have to

    1. Get the entire state of the thing being voted on – maximising the interface between client and server

    2. Update the counter

    3. Put back the updated state – oops, someone already updated the
      resource in the meantime!

    The server now has no easy way to handle multiple votes from the same person without managing some state ‘on the side’. We also have that ‘lost update’ problem.

    Things quickly get complicated.

    Final advice

    The decision on how you model something should be driven by what you need the system to do.

    There is often no correct decision, just the best compromise between effort and value.

    Choose a design which most easily implements the most common Use Cases. Common things should be quick and simple to do, uncommon things need only be possible.

    Chris

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database of words (including nouns and verbs). Now I would like
I have this php code $filename = verbs.php; // http://alylores.x10.mx/vega/verbs2.php $handle = fopen($filename, r);
By convention classes are often named like nouns, methods like verbs and interfaces like
I want to implement the recently approved PATCH HTTP verb in a RESTful service
Basically what the title says, I want to get the URL and HTTP Verb
Is there any data regarding how browsers actually support rest http verbs (especially PUT,
The only problem with Replace-Something name is: WARNING: The names of some imported commands
What is the minimum set of HTTP verbs that a server should allow for
I find the defs circular, the subjects are defined by their verbs but the
If I have defined the following types: type category = Noun | Verb |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.