Skip to end of metadata
Go to start of metadata


An include filter enables you to include results from related models in a query, for example models that have belongsTo or hasMany relations, to optimize the number of requests.  See Creating model relations for more information.

The value of the include filter can be a string, an array, or an object.

Icon

You can use an include filter with find(), findOne() and findById().

REST API

filter[include][relatedModel]=propertyName
You can also use stringified JSON format in a REST query.

Node API

Icon

Methods of models in the AngularJS client have a different signature than those of the Node API. For more information, see AngularJS SDK API.

{include: 'relatedModel'}
{include: ['relatedModel1', 'relatedModel2', ...]}
{include: {relatedModel1: [{relatedModel2: ‘propertyName’} , ‘relatedModel’]}}
Where:

  • relatedModel, relatedModel1, and relatedModel2 are the names (pluralized) of related models.
  • propertyName is the name of a property in the related model.

Examples

Include relations without filtering:

Return all post owners (users), and all orders of each owner:

Return all post owners (users), and all friends and orders of each owner:

Return all post owners (users), and all posts and orders of each owner. The posts also include images.

  • No labels