环回和默认排序
Loopback and default sorting
开始研究loopback。
我创建了我的应用程序,并低于此模型:
{
"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": "Error: ER_BAD_FIELD_ERROR: Unknown column 'id' in 'field list'\n
但我的 table 中没有 ID 字段。
我该如何解决这个问题?
如果模型属性的 none 作为 id 提及,Loopback 将自动添加一个 id
列。
假设对于您的模型,属性 mov_id
是 ID。通过添加 id: true
行在模型中定义:Reference
{
...
"properties": {
"mov_id": {
"type": "number",
"required": true,
"id":true
},
...
}
开始研究loopback。 我创建了我的应用程序,并低于此模型:
{
"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": "Error: ER_BAD_FIELD_ERROR: Unknown column 'id' in 'field list'\n
但我的 table 中没有 ID 字段。 我该如何解决这个问题?
如果模型属性的 none 作为 id 提及,Loopback 将自动添加一个 id
列。
假设对于您的模型,属性 mov_id
是 ID。通过添加 id: true
行在模型中定义:Reference
{
...
"properties": {
"mov_id": {
"type": "number",
"required": true,
"id":true
},
...
}