Sails v0.12.14
模型Category
:
module.exports = {
attributes: {
name: {
type: 'string'
},
brands: {
collection: 'Brand',
via: 'categories'
},
test: {
model: 'Brand'
}
}
}
在这种情况下
Category.findOne(1)
将预期结果返回为
{
id: 1,
name: 'category_name',
brand: 1
}
但是
Category.findOne(1).populate('test')
向响应添加空的brands
数组:
{
brands: [],
id: 1,
name: 'category_name',
test: {brand_object}
}
而
Category.findOne(1).populate('test').populate('brands')
仍然可以正常工作。