I want to indicate the relationship between 2 mssql tables. Paymentcategory and payments. paymentcategory.id is attached to the payout.category column.
in the payout.json model, I indicated as foreignKey: id,
"relations": {
"paymentcategories": {
"type": "hasOne",
"model": "Paymentcategory",
"foreignKey": "id"
}
but loopback looks by default for id field as primaryKey
Is it possible to specify a connection in the category field. Preferably in the file common / models / payout.json?
"relations": {
"paymentcategories": {
"type": "hasOne",
"model": "Paymentcategory",
"foreignKey": "id",
"primaryKey": "category" ??????????????????
}
Now I get this error:
"error": {
"name": "Error",
"status": 400,
"message": "Key mismatch: Paymentpayout.id: undefined, Paymentcategory.id: 1",
"statusCode": 400,
source
share