Reputation: 495
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"
}
}
}
Upvotes: 1
Views: 2163
Reputation: 1536
The question has been answered by: https://groups.google.com/d/msg/loopbackjs/H7ivcbLAaHo/C9iQop4RXAYJ
Upvotes: 2