[英]Loopback and default sorting
我开始研究环回。 我创建了我的应用,并且在此模型下:
{
"name": "movimenti",
"plural": "movimenti",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"mov_id": {
"type": "number",
"required": true
},
"mov_tipo": {
"type": "string",
"required": true
},
"mov_valore": {
"type": "number",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
我将模型连接到我的MySQL数据库:
"movimenti": {
"dataSource": "banca",
"public": true
}
我启动了该应用程序,然后转到指示的地址。 我质疑GET方法,并出现以下错误:
“ stack”:“错误:ER_BAD_FIELD_ERROR:”字段列表“中的未知列'id'\\ n
但我的表中没有ID字段。 我该如何解决这个问题?
如果没有将模型的任何属性作为ID提及,则环回将自动添加id
列。
假设对于您的模型,属性mov_id
是ID。 在模型中通过添加id: true
定义id: true
行: 参考
{
...
"properties": {
"mov_id": {
"type": "number",
"required": true,
"id":true
},
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.