Chinese Documentation : Include(加载导航属性)过滤器


include过滤器可以使得你在一个查询结果中include到相关的模型。 for example models that have belongsTo or hasMany relations, to optimize the number of requests.  See Creating model relations for more information.

include过滤器的值可以是字符串,数组,或者一个对象。

Icon

注意了include过滤器只能在find()和findOne()中使用,不能在findById()中使用。

REST API

filter[include][relatedModel]=propertyName
可以在REST query中使用stringified JSON format

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, 和 relatedModel2 是相关模型的名字(复数形式)。
  • propertyName 是相关模型的属性名。

例子

没有在Include中使用过滤器

REVIEW COMMENT from $paramName
Include examples from iCars. Problem: Need to create reservations to see any related models?

返回所有帖子的作者和作者的所有订单:

返回所有帖子的作者,作者的所有朋友和作者的所有订单:

返回所有帖子的作者,作者的所有帖子和作者的所有订单。帖子同样还include了图片。