nodejs,回送更改模型名称/表名称(使用mysql) [英] nodejs, Loopback change model name / table name (with mysql)
本文介绍了nodejs,回送更改模型名称/表名称(使用mysql)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在MySQL中使用Loopback(nodejs).
use Loopback(nodejs) with mysql.
我想更改型号名称/表名称. (不同的名称)
I want to change the model name/table name. (different name)
我不想看到表名(在API URL中)
I don't want to see table name (in API URL)
table name = 'super_member'
model name = 'member'
api url = '/api/member/';
我该怎么办?
推荐答案
您可以通过在模型和/或属性上添加mysql
属性来自定义模型:
You can customize models by adding a mysql
property on the model and/or on the properties :
{
"name": "yourModelName",
"base": "PersistedModel",
"idInjection": false,
"mysql": {
"schema": "YOUR DATABASE NAME",
"table": "YOUR MYSQL TABLE NAME"
},
"properties": {
"PropertyOne": {
"type": "Number"
"required": true,
"mysql": {
"columnName": "YOUR MYSQL COLUMN NAME",
"dataType": "int",
"dataLength": null,
"dataPrecision": 10,
"dataScale": 0,
"nullable": "N"
},
"_selectable": false
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
这篇关于nodejs,回送更改模型名称/表名称(使用mysql)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文