Loopback HasManyThrough关系只能以一种方式工作

我有两个模型“Jobdetails”和“工作渠道”,通过模型“JobDetailsHasVenues”具有“HasManyThrough”关系

Jobdetails型号:

{ "name": "Jobdetails", "properties": { "jobname": { "type": "String", "required": true, "length": 250, "precision": null, "scale": null, "mysql": { --- }, "_selectable": false } }, "relations": { "jobvenues": { "type": "hasMany", "model": "Jobvenues", "foreignKey": "jobdetailsId", "through": "JobdetailsHasVenues" } } 

和工作模式如下:

 { "name": "Jobvenues", "properties": { "storename": { "type": "String", "required": true, "length": 200, "precision": null, "scale": null, "mysql": { ---- }, "_selectable": false } } "relations": { "jobdetails": { "type": "hasMany", "model": "Jobdetails", "foreignKey": "venueId", "through": "JobdetailsHasVenues" } } 

穿透模式被定义为

  { "name": "JobdetailsHasVenues", { "jobdetailsid": { "type": "Number", "required": true, "length": null, "precision": 10 ---, "venueid": { "type": "Number", "required": true, "length": null, "precision": 10 ---- }, }, "relations": { "jobdetail": { "type": "belongsTo", "model": "Jobdetails", "foreignKey": "jobdetailsId" }, "jobvenue": { "type": "belongsTo", "model": "Jobvenues", "foreignKey": "venueId" } } 

当我查询

  Jobdetails.find({ filter:{ where:{and:[{'status':{neq:3}},{'id':{neq:jobId}}]}, include:'jobvenues' } }) 

结果中不存在就业渠道。 但是,如果我查询

  Jobvenues.find({ filter:{ where:{venueid:jobdetailsId}}]}, include:'jobdetails' } }) 

结果我可以看到相关的工作细节…..

我已经提到很多职位,包括Strong Loop的文档

这里是Stackoverflow

但不能让我的代码正常工作…..

再观察一下…如果我通过Loopback Explorer进行查询并通过GET / Jobdetails / {id} / jobsvenues进行查询 – 我可以看到相关的工作渠道。

但是,如果在查询GET / Jobdetails / {id}中使用“包含filter”,则会获得空行数的工作通道。

尝试添加键入

 "jobvenues": { "type": "hasMany", "model": "Jobvenues", "foreignKey": "jobdetailsId", "through": "JobdetailsHasVenues", "keyThrough": "venueId" } "jobdetails": { "type": "hasMany", "model": "Jobdetails", "foreignKey": "venueId", "through": "JobdetailsHasVenues", "keyThrough": "jobdetailsId" }