范围 属性 未应用于环回模型
scope property is not being applied to loopback model
我在 request.json 文件的范围内使用了 "include" : "organization"
查询,这是一个相关模型。但是,该关系未包含在查询的结果输出中。
模型(request.json 文件)看起来像...
{
"name": "request",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"amount": {
"type": "number",
"required": true
},
"deadline": {
"type": "date",
"required": true
}
},
"validations": [],
"relations": {
"organization": {
"type": "belongsTo",
"model": "organization",
"foreignKey": "",
"options": {
"nestRemoting": true
}
}
},
"scope" : {
"include" : "organization"
}
}
为了包含另一个模型,您必须在模型关系中定义 foreignKey
。
"relations": {
"organization": {
"type": "belongsTo",
"model": "organization",
"foreignKey": "organizationId",
"options": {
"nestRemoting": true
}
}
},
设置您要使用的外键的名称。 organizationId
在这种情况下,此字段将添加到您的模型中 request
我在 request.json 文件的范围内使用了 "include" : "organization"
查询,这是一个相关模型。但是,该关系未包含在查询的结果输出中。
模型(request.json 文件)看起来像...
{
"name": "request",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"amount": {
"type": "number",
"required": true
},
"deadline": {
"type": "date",
"required": true
}
},
"validations": [],
"relations": {
"organization": {
"type": "belongsTo",
"model": "organization",
"foreignKey": "",
"options": {
"nestRemoting": true
}
}
},
"scope" : {
"include" : "organization"
}
}
为了包含另一个模型,您必须在模型关系中定义 foreignKey
。
"relations": {
"organization": {
"type": "belongsTo",
"model": "organization",
"foreignKey": "organizationId",
"options": {
"nestRemoting": true
}
}
},
设置您要使用的外键的名称。 organizationId
在这种情况下,此字段将添加到您的模型中 request