包含内部位置的环回查询

Loopback query with where inside include

我正在尝试通过以下方式查询我的数据:

const filter = {where: {activity_id: activity_id, include: {relation: 'planGoal', scope: {where: {activity_goal_id: goal_id}}}}};

然而,这似乎不起作用,仅应用了 activity_id 过滤器并返回了错误的数据。

所以我的问题是如何在包含中查询数据?甚至有可能吗?

作为参考,以下是有问题的模型:

    {
  "name": "plan_goal_has_action_option",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "id": {
      "type": "number"
    },
    "activity_id": {
      "type": "number"
    },
    "plan_has_goal_id": {
      "type": "number"
    },
    "action_option": {
      "type": "string"
    }
  },
  "validations": [],
  "relations": {
    "planGoal": {
      "type": "belongsTo",
      "model": "plan_has_goal",
      "foreignKey": "plan_has_goal_id"
    }
  },
  "acls": [],
  "methods": {}
}


    {
  "name": "plan_has_goal",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "id": {
      "type": "number"
    },
    "activity_id": {
      "type": "number"
    },
    "activity_goal_id": {
      "type": "number"
    }
  },
  "validations": [],
  "relations": {
    "goal": {
      "type": "belongsTo",
      "model": "activity_goal",
      "foreignKey": "activity_goal_id"
    },
    "actions": {
      "type": "hasMany",
      "model": "plan_goal_has_action_option",
      "foreignKey": "plan_has_goal_id"
    }
  },
  "acls": [],
  "methods": {}
}

includewhere 是两个不同的过滤器:

{  
  where: {
    activity_id: activity_id
  },
  include: {  
    relation: 'planGoal',
    scope: {
      where: {
        activity_goal_id: goal_id
      }
    }
  }
}