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.
loopbackjs
add a comment |
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.
loopbackjs
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
add a comment |
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.
loopbackjs
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
loopbackjs
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
add a comment |
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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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