【问题标题】:nodejs, Loopback change model name / table name (with mysql)nodejs,Loopback 更改模型名/表名(带mysql)
【发布时间】:2019-01-02 23:05:47
【问题描述】:

在 mysql 中使用 Loopback(nodejs)。

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

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

table name = 'super_member'

model name = 'member'

api url = '/api/member/';

我能做什么?

【问题讨论】:

  • 也许,我解决了这个问题。只需在 model.json 中设置“复数”......认为看这个问题......

标签: node.js loopback


【解决方案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": {}
}

【讨论】:

  • 哇,我喜欢这个解决方案。非常感谢。你是个好老师!!
  • mongodb 呢?
猜你喜欢
  • 2016-12-14
  • 1970-01-01
  • 2018-01-24
  • 2016-12-30
  • 1970-01-01
  • 1970-01-01
  • 2023-01-31
  • 2014-12-25
  • 2016-12-29
相关资源
最近更新 更多