nodejs,回送更改模型名称/表名称(使用mysql)

时间:2019-01-02 07:57:12

标签: node.js loopback

在MySQL中使用Loopback(nodejs)。

我想更改型号名称/表名称。 (不同的名称)

我不想看到表名(在API URL中)

table name = 'super_member'

model name = 'member'

api url = '/api/member/';

我该怎么办?

1 个答案:

答案 0 :(得分:1)

您可以通过在模型和/或属性上添加mysql属性来自定义模型:

{
  "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": {}
}