当我使用仅具有必填字段的对象发布到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": {}`
答案 0 :(得分:0)
然后,您需要为模型创建默认值,例如城市:
"properties": {
"city": {
"type": "string",
"length": 100,
"default": ""
},
...
答案 1 :(得分:0)
在您的控制器中,创建新记录并获得记录ID后,执行sqlite3
查询并返回该对象,而不是从findById
返回的对象。这应该给您类似于GET路线的响应。