Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

update, remove and patch many #144

Copy link
Copy link
@daffl

Description

@daffl
Issue body actions

Sometimes you want to update multiple resources e.g. via REST sending a PUT /todos or DELETE /todos. Supporting this is fairly easy, the question is what method signatures to use. Currently I see two options.

Option 1: *Many service methods

We could add updateMany, patchMany and removeMany (and possibly createMany although it would just be passing an array to create).

var myService = {
  find: function(params, callback) {},
  get: function(id, params, callback) {},
  create: function(data, params, callback) {},
  update: function(id, data, params, callback) {},
  updateMany: function(data, params, callback) {},
  patch: function(id, data, params, callback) {},
  patchMany: function(data, params, callback) {},
  remove: function(id, params, callback) {},
  removeMany: function(params, callback) {},
  setup: function(app) {}
}
  • + Backwards compatible
  • - Cluttered service interface

Option 2: null values for id

The other option is to pass a null value as an id when operating on multiple resources.

app.use('/todos', {
  remove: function(id, params, callback) {
    if(id === null) {
    }
  }
}
  • + Keeps service interface the same
  • - Could break backwards compatibility in some cases (although you would most likely just return a notFound error)
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.