1

What should a models.json look like when I want to define that a Organization has many Organizations?

I tried to define a hasMany through relationshio, using an intermediate model called clients but it didn't work:

"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"
      }
    }
  }
Julian
  • 505
  • 2
  • 10

1 Answers1

2

The question has been answered by: https://groups.google.com/d/msg/loopbackjs/H7ivcbLAaHo/C9iQop4RXAYJ

Raymond Feng
  • 1,516
  • 9
  • 5