环回包括两种型号
loopback include with two models
当前代码有效:
app.models.AvionPiloteAutorisation.find({
"where": {
"idAvion": avion.idAvion
},
"include": ["pilote"]
}, function(err, pilotes) { ... }
但是这个:
app.models.AvionPiloteAutorisation.find({
"filter": {
"where": {
"idAvion": avion.idAvion
},
"include": {
"relation": "pilote"
}
}
})
失败。
应该是一样的吧?
我正在尝试使用相关模型添加一些信息 'Utilisateur'
app.models.AvionPiloteAutorisation.find({
"filter": {
"where": {
"idAvion": avion.idAvion
},
"include": {"relation": "pilote", "scope": {"include": ["utilisateur"]}}
}
})
我做错了什么?
谢谢。
第一个问题的答案是为什么第二段代码失败是因为当您使用 Angular SDK 到达终点时使用了涉及 "filter" 的语法。
我认为这段代码将实现您在这里尝试做的事情:-
app.models.AvionPiloteAutorisation.find({ "include":[{ "pilote": "utilisateur" }], "where":{ "idAvion": avion.idAvion } })
当前代码有效:
app.models.AvionPiloteAutorisation.find({
"where": {
"idAvion": avion.idAvion
},
"include": ["pilote"]
}, function(err, pilotes) { ... }
但是这个:
app.models.AvionPiloteAutorisation.find({
"filter": {
"where": {
"idAvion": avion.idAvion
},
"include": {
"relation": "pilote"
}
}
})
失败。 应该是一样的吧?
我正在尝试使用相关模型添加一些信息 'Utilisateur'
app.models.AvionPiloteAutorisation.find({
"filter": {
"where": {
"idAvion": avion.idAvion
},
"include": {"relation": "pilote", "scope": {"include": ["utilisateur"]}}
}
})
我做错了什么?
谢谢。
第一个问题的答案是为什么第二段代码失败是因为当您使用 Angular SDK 到达终点时使用了涉及 "filter" 的语法。
我认为这段代码将实现您在这里尝试做的事情:-
app.models.AvionPiloteAutorisation.find({ "include":[{ "pilote": "utilisateur" }], "where":{ "idAvion": avion.idAvion } })