Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restful Mass-Action

Tags:

rest

extjs

I'm currently working on a restful-API for an existing product, and come to a quite tricky problem: The Existing application supports several mass actions, i.e. mass-delete or grids for mass-setting certain properties of records. Using the usual restful-pattern, i`d have to send a api-call for each record, (DELETE or UPDATE), but with large amounts of records this will obviously be quite slow. so i was wondering, if someone already found a good solution for this, especially regarding usage with existing restful-technology (like Extjs restful store). So far if come up with these possible solutions:

  • Making my restful controllers use a reserved parameter ("_requests" or something) as an array and mapping each item to a single call internally.
  • using a seperate controller for each mass-action i want. This seems cleaner, but way more work, both on the backend and the application using the API.

Any thoughts?

like image 203
Fivetide Avatar asked Oct 29 '25 09:10

Fivetide


1 Answers

RESTful things act on Resources, so perhaps have the URI refer to a collection (even describing the collection if needed), and post a delete to that URI. In RESTful terms, you're passing the collection resource in a deleted state to its URI. So:

Delete -> stub/collections/ids=141,159,235,900

like image 175
Phil H Avatar answered Oct 31 '25 13:10

Phil H