我想指定2个mssql表之间的关系.Paymentcategory和支付.paymentcategory.id加入payout.category列.
在payout.json模型中我指定为foreignKey:id,
"relations": {
"paymentcategories": {
"type": "hasOne",
"model": "Paymentcategory",
"foreignKey": "id"
}
Run Code Online (Sandbox Code Playgroud)
但是对于id字段,loopback默认为primaryKey
有没有办法在类别字段上指定连接.最好在common/models/payout.json文件中?
"relations": {
"paymentcategories": {
"type": "hasOne",
"model": "Paymentcategory",
"foreignKey": "id",
"primaryKey": "category" ??????????????????
}
Run Code Online (Sandbox Code Playgroud)
现在我收到这个错误:
"error": {
"name": "Error",
"status": 400,
"message": "Key mismatch: Paymentpayout.id: undefined, Paymentcategory.id: 1",
"statusCode": 400,
Run Code Online (Sandbox Code Playgroud)
小智 1
您可以将外键定义为您想要的任何内容(在/common/models/your-model-name.json.
有关更多信息,请参阅我的示例:https://github.com/strongloop/loopback-example-relations-basic 。
| 归档时间: |
|
| 查看次数: |
2097 次 |
| 最近记录: |