title: Sails.js - How to update model with associations
body: <p>I am trying to work with Models with associations. I have two models defined as following:</p>
  
  <p><strong>User.js</strong></p>
  
  <pre><code>module.exports = {schema: true, attributes: {
     userId: {
         autoIncrement: true,
         type: integer,
         primaryKey: true,
     },
     userId: {type: integer},
     email: {type:string, size:200},
     addressId: {
        model:UserAddress
     }
  }
  </code></pre>
  
  <p><strong>Address.js</strong></p>
  
  <pre><code>module.exports = {schema: true, attributes: {
    addressId: {
       autoIncrement: true,
       type:integer,
       primaryKey:true
    },
    userId: {type:integer},
    address: {type:string, size:250}
  }
  </code></pre>
  
  <p>So far, I was able to CREATE records in both models by POSTing following JSON to  </p>
  
  <pre><code>http://localhost:1337/user/
  
  {
      "userName": "John",
      "userId": "3",
      "email":"john@hotmail.com",
      "addressId": {
          "userId": "3",
          "address": "123 abc street"
       }
   }
  </code></pre>
  
  <p>I was able to UPDATE both records using PUT with this URL:
  <code>http://localhost:1337/user/update/1</code>and JSON below, note that I have added <strong>addressId</strong> in the nested JSON in this case. </p>
  
  <pre><code>{
      "userName": "John",
      "userId": "3",
      "accountLogin":"john@hotmail.com",
      "addressId": {
          "addressId":1,
          "userId": "3",
          "streetAddress": "123 abc street"
       }
  }
  </code></pre>
  
  <p>However, when I first created a record in the User table without an address and later wanted to add it, I had no luck to make it work. What I did was using PUT against <code>http://localhost:1337/user/update/1</code> with following JSON, since the address is new, there's no addressId. </p>
  
  <pre><code>{
      "userName": "John Doe",
      "accountLogin":"john@hotmail.com",
      "addressId": {
          "userId": "3",
          "streetAddress": "123 abc street"
       }
  }
  </code></pre>
  
  <p>Is there a way to do what I was trying to do in Sails.js? I could just Post to <code>http://localhost:1337/address</code> to create a new record, but I want to make my API consistent is possible. The more serious problem is, when above JSON was sent, it crashed the backend. It seems to me that user can easily crash backend by sending invalid JSON, how would I protect backend from this kind of crashing?</p>