Update embedded models in Loopback 4









up vote
0
down vote

favorite












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.



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:



Exception:
Unhandled error in PATCH /5be3e00aad0df83d10e580d1: 500 TypeError: Class constructor Question cannot be invoked without 'new'
at Function.DataAccessObject._coerce (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:1799:22)
at doUpdate (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2735:20)
at C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2714:11
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2699:11
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)



Sample PATCH request:
[
"title": "Some survey title 1",
"description": "Some survey title 1",
"questions": [
"options": [
"description": "Some option description 1",
"type": "Option"
],
"description": "Some question description 1"
]
]



Have not been able to find any helpful information on this yet. Any pointers please?



Thanks in advance.










share|improve this question





















  • I think you have most likely discovered a bug/missing feature of LB4. Can you open a GitHub issue please? github.com/strongloop/loopback-next/issues
    – Miroslav Bajtoš
    Nov 9 at 16:04










  • Thank you for your response Miroslav! Yes, i think i will have to do that.
    – naveenkumashi
    Nov 10 at 8:16














up vote
0
down vote

favorite












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.



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:



Exception:
Unhandled error in PATCH /5be3e00aad0df83d10e580d1: 500 TypeError: Class constructor Question cannot be invoked without 'new'
at Function.DataAccessObject._coerce (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:1799:22)
at doUpdate (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2735:20)
at C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2714:11
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2699:11
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)



Sample PATCH request:
[
"title": "Some survey title 1",
"description": "Some survey title 1",
"questions": [
"options": [
"description": "Some option description 1",
"type": "Option"
],
"description": "Some question description 1"
]
]



Have not been able to find any helpful information on this yet. Any pointers please?



Thanks in advance.










share|improve this question





















  • I think you have most likely discovered a bug/missing feature of LB4. Can you open a GitHub issue please? github.com/strongloop/loopback-next/issues
    – Miroslav Bajtoš
    Nov 9 at 16:04










  • Thank you for your response Miroslav! Yes, i think i will have to do that.
    – naveenkumashi
    Nov 10 at 8:16












up vote
0
down vote

favorite









up vote
0
down vote

favorite











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.



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:



Exception:
Unhandled error in PATCH /5be3e00aad0df83d10e580d1: 500 TypeError: Class constructor Question cannot be invoked without 'new'
at Function.DataAccessObject._coerce (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:1799:22)
at doUpdate (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2735:20)
at C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2714:11
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2699:11
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)



Sample PATCH request:
[
"title": "Some survey title 1",
"description": "Some survey title 1",
"questions": [
"options": [
"description": "Some option description 1",
"type": "Option"
],
"description": "Some question description 1"
]
]



Have not been able to find any helpful information on this yet. Any pointers please?



Thanks in advance.










share|improve this question













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.



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:



Exception:
Unhandled error in PATCH /5be3e00aad0df83d10e580d1: 500 TypeError: Class constructor Question cannot be invoked without 'new'
at Function.DataAccessObject._coerce (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:1799:22)
at doUpdate (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2735:20)
at C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2714:11
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibdao.js:2699:11
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at doNotify (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at Function.ObserverMixin._notifyBaseObservers (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
at Function.ObserverMixin.notifyObserversOf (C:UsersnkDocumentsProjectbackendsurveyServicenode_modulesloopback-datasource-jugglerlibobserver.js:153:8)



Sample PATCH request:
[
"title": "Some survey title 1",
"description": "Some survey title 1",
"questions": [
"options": [
"description": "Some option description 1",
"type": "Option"
],
"description": "Some question description 1"
]
]



Have not been able to find any helpful information on this yet. Any pointers please?



Thanks in advance.







loopbackjs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 9 at 13:56









naveenkumashi

112




112











  • I think you have most likely discovered a bug/missing feature of LB4. Can you open a GitHub issue please? github.com/strongloop/loopback-next/issues
    – Miroslav Bajtoš
    Nov 9 at 16:04










  • Thank you for your response Miroslav! Yes, i think i will have to do that.
    – naveenkumashi
    Nov 10 at 8:16
















  • I think you have most likely discovered a bug/missing feature of LB4. Can you open a GitHub issue please? github.com/strongloop/loopback-next/issues
    – Miroslav Bajtoš
    Nov 9 at 16:04










  • Thank you for your response Miroslav! Yes, i think i will have to do that.
    – naveenkumashi
    Nov 10 at 8:16















I think you have most likely discovered a bug/missing feature of LB4. Can you open a GitHub issue please? github.com/strongloop/loopback-next/issues
– Miroslav Bajtoš
Nov 9 at 16:04




I think you have most likely discovered a bug/missing feature of LB4. Can you open a GitHub issue please? github.com/strongloop/loopback-next/issues
– Miroslav Bajtoš
Nov 9 at 16:04












Thank you for your response Miroslav! Yes, i think i will have to do that.
– naveenkumashi
Nov 10 at 8:16




Thank you for your response Miroslav! Yes, i think i will have to do that.
– naveenkumashi
Nov 10 at 8:16

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53227079%2fupdate-embedded-models-in-loopback-4%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53227079%2fupdate-embedded-models-in-loopback-4%23new-answer', 'question_page');

);

Post as a guest














































































Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo