1

当我想定义一个组织有很多组织时,models.json 应该是什么样子?

我试图通过relationshio定义一个hasMany,使用一个名为clients的中间模型,但它没有用:

"organization": {
  "properties": {
    "name": {
      "type": "string"
    }
  },
  "relations": {
    "clients": {
      "type": "hasMany",
      "model": "organization",
      "foreignKey": "clientId",
      "through": "client"
    }
  }
  "client": {
    "properties": {
      "organizationId": {
        "type": "number",
        "id": true
      },
      "clientId": {
        "type": "number",
        "id": true
      }
    },
    "relations": {
      "organization": {
        "type": "belongsTo",
        "model": "organization",
        "foreignKey": "organizationId"
      },
      "client": {
        "type": "belongsTo",
        "model": "organization",
        "foreignKey": "clientId"
      }
    }
  }
4

1 回答 1

2

该问题已由以下人员回答:https ://groups.google.com/d/msg/loopbackjs/H7ivcbLAaHo/C9iQop4RXAYJ

于 2014-06-11T18:49:54.790 回答