2017-04-04 42 views
0

嵌套关系我有这样一个查询:“或”过滤器在环回查找查询

Members.app.models.MobileUserAlertRelation.find({where: {userId: userId}, include: {relation: "alerts", scope: {where: {title: 'testng'}, include: {relation: "alertTypes", scope: {where: {alertTypeName: "test"}}}}}}, function(err, result) { 
     console.log(result); 
}); 

这里MobileUserAlertRelation模式有关系,“警报”,并提醒模式有关系“alertTypes”。 我想要实现的是:找到警报中的标题字段是“testng”还是alertTypes中的alertTypeName字段是“test”。

Table structure is like: 
MobileUserAlertRelation: fields {id, userId, alertId} 
Alerts: fields {id, title, alertTypeId} 
AlertTypes: fields {id, alertTypeName} 

即, AlertType关系嵌套在警报关系中。 这怎么办?任何帮助,将不胜感激。请让我知道是否需要更多的澄清。

回答

0

我和你在同一条船上,发现你不能查询相关模型(还)。

https://github.com/strongloop/loopback/issues/517

我的解决方法是重新安排我的关系,我也做了一个原生查询解析器。我做了一个钩子,它做了一个本地查询,它加入了与属性的关系。