loopbackjs - LoopBackJs REST API 创建响应不返回完整模型,只返回表单数据
问题描述
当我使用仅包含必填字段的对象发布到 api/testmodel 时,该对象正在数据库中正确创建。但是,我只得到我在请求正文中发送的对象。我正在尝试获取响应中包含空字段的完整对象。
谢谢您的帮助!
{
"name": "test",
"plural": "test",
"base": "PersistedModel",
"idInjection": true,
"replaceOnPUT": false,
"properties": {
"city": {
"type": "string",
"length": 100
},
"name": {
"type": "string",
"required": true,
"length": 100
},
"id": {
"type": "string",
"id": true,
"required": true,
},
"officePhone": {
"type": "string",
"length": 100
},
"status": {
"type": "string",
"required": false,
"length": 200
},
"street": {
"type": "string",
"length": 100
}
},
"methods": {}`
解决方案
然后你需要为你的模型创建默认值,例如城市:
"properties": {
"city": {
"type": "string",
"length": 100,
"default": ""
},
...
推荐阅读
- java - Libgdx:添加到特定场景时无法单击按钮或查看对话框窗口
- android - 如何解决公共抽象乐趣入队的参数过多(responseCallback:Callback):okhttp3.Call中定义的单位
- spring-cloud - 需要澄清将发现客户端与原生 Kubernetes 发现一起使用
- javafx - 如何在 JavaFX 渐变中插入颜色?
- android - 清单在哪里?
- javascript - 在 div 上拖放堆叠多个图像
- css - 在 react-split 中嵌入 react-ace
- python - 尝试使用列表通过 ref 传递参数不起作用?
- sql - 如何配置 Postgres 变量?
- google-cloud-firestore - Firestore:批量更新插入文档