title: RESTful API endpoint for adding/removing array elements?
body: <p>I have RESTful API built on top of a MongoDB store, so it's nice that you can store arrays. It's straightforward to create a new resource like this:</p>
  
  <p><code>POST /users</code>
  <code>
  {
    items: [
      1001, 1002, 1003
    ]
  }
  </code></p>
  
  <p>But how would the HTTP endpoint for adding a new item or removing an item would look like?</p>
  
  <p>Right now, I have to specify the entire array, including elements that I don't want to touch:</p>
  
  <p><code>PATCH /users/{id}</code>
  <code>
  {
    name: 'Bruce Wayne',
    items: [
      1001, 1002
    ]
  }
  </code></p>
  
  <p>Or pass in a mongodb query directly:</p>
  
  <p><code>PATCH /users/{id}?query[$push][items]=1003</code></p>
  
  <p>Is there a better way to do this?</p>
  
  <p>Edit:</p>
  
  <p>I like how <a href="https://developer.stackmob.com/sdks/rest/api#a-arrays_and_relationships" rel="noreferrer">StackMob's API</a> does it. How do I update the <code>name</code> and remove an element from <code>items</code> at the same time though? For example, when I'm updating a bunch of the user's details on an admin dashboard? I don't think replacing the entire array is a good idea in mongodb?</p>