gpt4 book ai didi

node.js - Strongloop Loopback中如何定义一个模型有多个相同的模型?

转载 作者:太空宇宙 更新时间:2023-11-03 23:40:47 24 4
gpt4 key购买 nike

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

我尝试使用名为“clients”的中间模型通过关系来定义 hasMany,但它不起作用:

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

最佳答案

关于node.js - Strongloop Loopback中如何定义一个模型有多个相同的模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24165151/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com