Sails.js 在“查找路线”上填充了关联字段,且“蓝图”选项处于启用状态

Sails.js 在“查找路线”上填充了关联字段,且“蓝图”选项处于启用状态,sails.js,waterline,model-associations,sails-permissions,Sails.js,Waterline,Model Associations,Sails Permissions,我的应用程序有一个“类别”模型 类别可以是其他类别的子类别 所以有一个“分类关联”模型 代码如下: /* api/models/Categories.js */ module.exports = { attributes: { name: { type: "string" }, parents: { collection: "categoriesassociations", via: "child" }, chi

我的应用程序有一个“类别”模型

类别可以是其他类别的子类别

所以有一个“分类关联”模型

代码如下:

/* api/models/Categories.js */ 

module.exports = {
  attributes: {
    name: {
      type: "string"
    },
    parents: {
      collection: "categoriesassociations",
      via: "child"
    },
    children: {
      collection: "categoriesassociations",
      via: "parent"
    }
  }
}

/* api/models/CategoriesAssociations.js */ 

module.exports = {
  attributes: {
    parent: {
      model: "categories"
    },
    child: {
      model: "categories"
    }
  }
}
现在,当我使用
find
route aka
/categories
时,我得到以下信息:

[
  {
    "createdAt": "2015-08-24T14:16:46.662Z",
    "updatedAt": "2015-08-24T14:24:23.819Z",
    "name": null,
    "id": "55db274e424996cc7e7512e2"
  },
  {
    "createdAt": "2015-08-24T14:18:29.748Z",
    "updatedAt": "2015-08-24T14:18:41.105Z",
    "name": "test",
    "id": "55db27b5424996cc7e7512e4"
  }
]
[
  {
    "parent": "55db27b5424996cc7e7512e4",
    "child": "55db274e424996cc7e7512e2",
    "createdAt": "2015-08-24T14:32:43.429Z",
    "updatedAt": "2015-08-24T14:32:43.429Z",
    "id": "55db2b0bc97cc73083017f60"
  }
]
所以没有
父母
孩子
属性的痕迹

当我请求
/categories/55db27b54244996cc7e7512e4/children
时,关联确实是在数据库中创建的,我得到以下信息:

[
  {
    "createdAt": "2015-08-24T14:16:46.662Z",
    "updatedAt": "2015-08-24T14:24:23.819Z",
    "name": null,
    "id": "55db274e424996cc7e7512e2"
  },
  {
    "createdAt": "2015-08-24T14:18:29.748Z",
    "updatedAt": "2015-08-24T14:18:41.105Z",
    "name": "test",
    "id": "55db27b5424996cc7e7512e4"
  }
]
[
  {
    "parent": "55db27b5424996cc7e7512e4",
    "child": "55db274e424996cc7e7512e2",
    "createdAt": "2015-08-24T14:32:43.429Z",
    "updatedAt": "2015-08-24T14:32:43.429Z",
    "id": "55db2b0bc97cc73083017f60"
  }
]
Sails文档声明蓝图的
填充
配置键定义:

blueprint控制器是否应使用通过关联链接的其他模型的数据填充模型获取。如果在一对多关联中有大量数据,保持此状态可能会导致非常繁重的api调用

在我的项目中,该值为
true
,但仍然不会填充关联属性

我是否误解了文档,或者我的项目有问题

我使用sails 0.11.x

问题是我使用的是具有覆盖蓝图的填充配置:

sails.config.blueprints.populate = false;

我想知道为什么要在全球范围内进行此操作,以及如何解决此问题。

列出的模型中是否有这些属性的实际数据?也就是说,这两个模型实例是否有子对象和父对象?是的。关联表中有多个类别通过一条记录关联。@sgress454创建了标记