【发布时间】:2015-05-15 14:36:40
【问题描述】:
在sails.js 中,我有一个Post 模型,它与另一个名为“tag”的模型具有多对多关联
帖子模型
module.exports = {
attributes: {
title: 'string',
content: 'string',
coverImage: 'string',
owner: {
model: 'user'
},
tags: {
collection: 'ContentTag',
via: 'posts',
dominant: true // ---
}
}
};
标签模型
module.exports = {
attributes: {
name: 'string',
posts: {
collection: 'post',
via: 'tags'
}
}
};
现在我想获取具有相同标签的相关帖子。我尝试使用 .populate('tags') 和 .populate('tags',{name: ['tag1','tag2']) 但我不知道如何解决。
【问题讨论】: