loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Include Filter doesn't work for referencesMany relation

Open mackwan84 opened this issue 11 years ago • 1 comments

I am working on a ticketing system with loopback recently. I have defined a ticket model with a relation named "assignees" which reference to the model "EndUser" using referencesMany. However, when I try to list out all tickets with Include Filter, no assignees are returned from the query. Why?

Here is my model definition

{
  "name": "Ticket",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "title": {
      "type": "string",
      "required": true
    },
    "description": {
      "type": "string",
      "required": true
    },
    "status": {
      "type": "string",
      "default": "open"
    },
    "priority": {
      "type": "number",
      "default": 1
    },
    "source": {
      "type": "string"
    },
    "tags": {
      "type": [
        "string"
      ]
    },
    "created": {
      "type": "date",
      "defaultFn": "now"
    },
    "modified": {
      "type": "date",
      "defaultFn": "now"
    },
    "due": {
      "type": "date"
    }
  },
  "validations": [],
  "relations": {
    "requester": {
      "type": "belongsTo",
      "model": "EndUser",
      "foreignKey": "requesterId"
    },
    "assignees": {
      "type": "referencesMany",
      "model": "EndUser",
      "property": "assigneeIds",
      "options": {
        "validate": true,
        "forceId": true
      }
    }
  },
  "acls": [],
  "methods": {}
}

mackwan84 avatar Oct 23 '15 10:10 mackwan84

Please post questions at https://groups.google.com/forum/#!forum/loopbackjs. See h ttps://github.com/strongloop/loopback/wiki/Questions for more details.

superkhau avatar Oct 27 '15 00:10 superkhau