title: How to update related models with loopback
body: <p>I have to related models, Question which can have many Answer :</p>
  
  <p>Here's my question.json :</p>
  
  <pre><code>{
    "name": "Question",
    "base": "PersistedModel",
    "idInjection": false,
    "options": {
      "validateUpsert": true
    },
    "mysql": {
      "schema": "metal-quizz",
      "table": "Question"
    },
    "properties": {
      "id": {
        "type": "Number",
        "id": true,
        "required": true,
        "length": null,
        "precision": 10,
        "scale": 0,
        "mysql": {
          "columnName": "id",
          "dataType": "int",
          "dataLength": null,
          "dataPrecision": 10,
          "dataScale": 0,
          "nullable": "N"
        },
        "_selectable": false
      },
      "label": {
        "type": "String",
        "required": true,
        "length": 255,
        "precision": null,
        "scale": null,
        "mysql": {
          "columnName": "label",
          "dataType": "varchar",
          "dataLength": 255,
          "dataPrecision": null,
          "dataScale": null,
          "nullable": "N"
        },
        "_selectable": false
      },
      "level": {
        "type": "Number",
        "required": true,
        "length": null,
        "precision": 10,
        "scale": 0,
        "mysql": {
          "columnName": "level",
          "dataType": "int",
          "dataLength": null,
          "dataPrecision": 10,
          "dataScale": 0,
          "nullable": "N"
        },
        "_selectable": false
      }
    },
    "validations": [],
    "relations": {
      "answers": {
        "type": "hasMany",
        "model": "Answer",
        "foreignKey": "questionId"
      }
    },
    "acls": [],
    "methods": {}
  }
  </code></pre>
  
  <p>Here's my answer.json :</p>
  
  <pre><code>{
    "name": "Answer",
    "base": "PersistedModel",
    "idInjection": false,
    "options": {
      "validateUpsert": true
    },
    "mysql": {
      "schema": "metal-quizz",
      "table": "Answer"
    },
    "properties": {
      "id": {
        "type": "Number",
        "id": true,
        "required": true,
        "length": null,
        "precision": 10,
        "scale": 0,
        "mysql": {
          "columnName": "id",
          "dataType": "int",
          "dataLength": null,
          "dataPrecision": 10,
          "dataScale": 0,
          "nullable": "N"
        },
        "_selectable": false
      },
      "questionId": {
        "type": "Number",
        "required": true,
        "length": null,
        "precision": 10,
        "scale": 0,
        "mysql": {
          "columnName": "questionId",
          "dataType": "int",
          "dataLength": null,
          "dataPrecision": 10,
          "dataScale": 0,
          "nullable": "N"
        },
        "_selectable": false
      },
      "label": {
        "type": "String",
        "required": true,
        "length": 255,
        "precision": null,
        "scale": null,
        "mysql": {
          "columnName": "label",
          "dataType": "varchar",
          "dataLength": 255,
          "dataPrecision": null,
          "dataScale": null,
          "nullable": "N"
        },
        "_selectable": false
      },
      "status": {
        "type": "Number",
        "required": true,
        "length": null,
        "precision": 3,
        "scale": 0,
        "mysql": {
          "columnName": "status",
          "dataType": "tinyint",
          "dataLength": null,
          "dataPrecision": 3,
          "dataScale": 0,
          "nullable": "N"
        },
        "_selectable": false
      }
    },
    "validations": [],
    "relations": {
      "question": {
        "type": "belongsTo",
        "model": "Question",
        "foreignKey": ""
      }
    },
    "acls": [],
    "methods": {}
  }
  </code></pre>
  
  <p>I would like to have a web page with a form which displays a Question and all its related answers and allow me to update them all at the same time.
  I managed the display part without any problem but I'm getting nuts about the updating part.</p>
  
  <p>In theory it's possible since I can do it through the explorer via the following routes :</p>
  
  <pre><code>PUT /Questions/{id} to update question
  PUT /Questions/{id}/answers/{fk} to update answers individually
  </code></pre>
  
  <p>So I created a remote method to do so but I can't get to understand what method of the answers I am allowed to use to update them one by one:</p>
  
  <pre><code>Question.putWithDeps = function(question, cb) {
      // Update Question 
      Question.upsert(question, function(err, model) {
          // What code am I supposed to put here to update question.answers ???
      }
  };
  Question.remoteMethod(
      'putWithDeps',
      {
          http: {path: '/withDeps', verb: 'put'},
          accepts: {arg: 'instance', type: 'object'},
          returns: {root: true, type: 'object' } 
      }
  );
  </code></pre>
  
  <p>Am I getting it all wrong ?
  Thanks in advance.</p>