title: Update embedded models in Loopback 4
body: <p>I have the following model relationship in my LoopBack 4 application:
  A Survey has 1-many relationship with Question,
  Question has 1-many relationship with Option.</p>
  
  <p>Am using MongoDB as the database. I am unable to figure out how to implement a PUT/PATCH REST api, that can update the entire Survey model containing the Questions and Options. I get the following exception when i try a PATCH on the sample request JSON below:</p>
  
  <blockquote>
    <p>Exception:  Unhandled error in PATCH /5be3e00aad0df83d10e580d1: 500
    TypeError: Class constructor Question cannot be invoked without 'new'
        at Function.DataAccessObject._coerce (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\dao.js:1799:22)
        at doUpdate (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\dao.js:2735:20)
        at C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\dao.js:2714:11
        at doNotify (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:155:49)
        at doNotify (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:155:49)
        at Function.ObserverMixin._notifyBaseObservers (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:178:5)
        at Function.ObserverMixin.notifyObserversOf (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:153:8)
        at Function.ObserverMixin._notifyBaseObservers (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:176:15)
        at Function.ObserverMixin.notifyObserversOf (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:153:8)
        at C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\dao.js:2699:11
        at doNotify (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:155:49)
        at doNotify (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:155:49)
        at Function.ObserverMixin._notifyBaseObservers (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:178:5)
        at Function.ObserverMixin.notifyObserversOf (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:153:8)
        at Function.ObserverMixin._notifyBaseObservers (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:176:15)
        at Function.ObserverMixin.notifyObserversOf (C:\Users\nk\Documents\Project\backend\surveyService\node_modules\loopback-datasource-juggler\lib\observer.js:153:8)</p>
  </blockquote>
  
  <p>Sample PATCH request:</p>
  
  <pre><code>[{
      "title": "Some survey title 1",
      "description": "Some survey title 1",
      "questions": [{
          "options": [{
              "description": "Some option description 1",
              "type": "Option"
          }],
          "description": "Some question description 1"
      }]
  }]
  </code></pre>
  
  <p>Have not been able to find any helpful information on this yet. Any pointers please?</p>
  
  <p>Thanks in advance.</p>