0

I've read the document here: https://docs.strongloop.com/display/public/LB/Include+filter

But they are not clear! For example, they give the example:

User.find({include: 'posts'}, function() { ... });

Where should this code fit into? Is it in the common/models/user.js? Then what inside the function? what is the returned?

Of course I'm getting frustrated with their documents.

Please suggest. Thanks.

Vicheanak
  • 6,444
  • 17
  • 64
  • 98

1 Answers1

0

According to documentation you can use an include filter with find(), findOne() and findById(). I have attached links to respective sections of API reference.

To use these methods you need your PersistedModel object (e.g. User). Like you mentioned, you can get it in common/models/model-name.js (if you store your models there). You can also easily retrieve it from your LoopBackApplication object, which you can get in several ways. Bottom line is ... you can basically use these methods, wherever you need.

function() { ... } argument signalizes a callback. It lets you define a function which is going to be used on a returned instance(s). What is inside that function depends on your needs.

Ivan Schwarz
  • 814
  • 1
  • 14
  • 22