I am currently playing with associations in Sails.js beta (v 0.10.0-rc4).
I am trying to link multiple databases into one result (using sails-mysql).
The link looks like this: Post→ TagRelation→ Tag. And I, when I query the table Post, I want the returned object to include related names Tag.
Models look something like this:
// Post model
var Post = {
title: 'string',
body: 'string',
tag_relations: {
collection: 'TagRelation'
via: 'post_id'
}
};
// Tag Relation model
var TagRelation = {
post_id: {
model: 'Post'
},
tag_id: {
model: 'Tag'
}
};
// Tag model
var Tag = {
name: 'string',
tag_relations: {
collection: 'Tag',
via: 'tag_id'
}
};
Now, when I http://localhost:1337/post/1get to , I will get a JSON object with a key tag_relationscontaining an array of objects TagRelation, but is there a way to get a list of the actual objects Tagthey mean instead? Or is there a better way to do this?