我的LoopBack 4应用程序具有以下模型关系: 调查与“问题”具有1多关系, 问题与Option有1对多的关系。
我使用MongoDB作为数据库。我无法弄清楚如何实现PUT / PATCH REST api,该api可以更新包含问题和选项的整个Survey模型。当我在下面的示例请求JSON上尝试PATCH时,出现以下异常:
例外: PATCH / 5be3e00aad0df83d10e580d1中的未处理错误:500 TypeError:类构造函数如果没有“ new”,则无法调用问题 在Function.DataAccessObject._coerce(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ dao.js:1799:22) 在doUpdate(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ dao.js:2735:20) 在C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ dao.js:2714:11 在doNotify(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:155:49) 在doNotify(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:155:49) 在Function.ObserverMixin._notifyBaseObservers(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:178:5) 在Function.ObserverMixin.notifyObserversOf(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:153:8) 在Function.ObserverMixin._notifyBaseObservers(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:176:15) 在Function.ObserverMixin.notifyObserversOf(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:153:8) 在C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ dao.js:2699:11 在doNotify(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:155:49) 在doNotify(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:155:49) 在Function.ObserverMixin._notifyBaseObservers(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:178:5) 在Function.ObserverMixin.notifyObserversOf(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:153:8) 在Function.ObserverMixin._notifyBaseObservers(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:176:15) 在Function.ObserverMixin.notifyObserversOf(C:\ Users \ nk \ Documents \ Project \ backend \ surveyService \ node_modules \ loopback-datasource-juggler \ lib \ observer.js:153:8)
样本PATCH请求: [{ “ title”:“一些调查标题1”, “ description”:“一些调查标题1”, “问题”:[{ “选项”:[{ “ description”:“某些选项描述1”, “ type”:“选项” }], “ description”:“一些问题描述1” }] }]
目前尚未找到任何有用的信息。有指针吗?
谢谢。