Has many through find where is not working

26 views
Skip to first unread message

bogdan

unread,
Jul 15, 2016, 5:57:43 PM7/15/16
to LoopbackJS
Hi,

I have the following relation:

 "relations": {
    "categories": {
      "type": "hasMany",
      "model": "Category",
      "foreignKey": "recipeId",
      "through": "RecipeCategory"
    }
}

As you can see, this is a hasManyThrough relation, between Recipe and Category.
I want to build a search in Angular which should search in recipe name and selected categories, so I've reached this point:

      Recipe.find({
          filter: {
              where: {
                 name: {
                     like: 'test'
                 }
              }
              include: [ 'categories']
          }
      }, function(recipes) {
        console.log(recipes);
      }, function(err) {
        console.log(err);
      });
    }

but I don't know how to add the filter for categories ( AND categories selected_categories).
Can anyone help me please?

Thank you!

Eric Alves da Rocha

unread,
Jul 19, 2016, 9:13:54 AM7/19/16
to loopb...@googlegroups.com
​Hi!

​I have the same problem..

Look that:

{
  "relations": {
    "collectors": {
      "type": "hasMany",
      "model": "user",
      "foreignKey": "",
      "through": "collection",
      "keyThrough": "userId"
    }
  }
}


​Please, ​answer if this works for you.


Att.,
Eric A. da Rocha

--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/2e9636b9-b90a-4742-b84d-73d50311215c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

bogdan

unread,
Jul 20, 2016, 12:46:52 AM7/20/16
to LoopbackJS
Hi,

I've tried also using 'keyThrough', but it didn't worked for me..
Reply all
Reply to author
Forward
0 new messages