Search code examples
javascriptnode.jsstrongloop

how to filter data in include 'model' using strongloop


I am trying to join table ABC with XYZ, and to filter data of included table 'xyz' using Strongloop.

My code is:

 return ABC.find({filter:{ 
                    where: {abcPropertyName: {neq: '1234'}}, 
                    include: {**XYZ**: *[{xyzPropertyName: 'somevalue'}]*}}}).$promise

My data-source is:

____abc.json____

"relations": {
    "xyz": {
      "type": "hasOne",
      "model": "xyz",
      "foreignKey": "abcId"
    }

____xyz.json____

"relations": {
    "abc": {
      "type": "blongsTo",
      "model": "abc",
      "foreignKey": "abcId"
    }

Issue: filter in 'xyz' is not working. Please help. thanks in advance


Solution

  • Try to use the following include filter:

    include: { 
        relation: **XYZ**, 
        scope: {
          where: {xyzPropertyName: 'somevalue'} 
        }
    }
    

    Reference