So i'm developing an app using sails js. I want to send a thread along with it's comments as a response.
here's my model
Thread.js
module.exports = {
attributes: {
id: {
type: "integer",
primaryKey: true,
autoIncrement: true
},
title: "string",
content: "string",
userId: {
model: "user"
},
createdAt: "string",
isSecret: "boolean",
comments: {
collection: "comment",
via: "threadId"
}
}
};
Comment.js
module.exports = {
attributes: {
id: {
type: "integer",
primaryKey: true,
autoIncrement: true
},
threadId: {
model: "thread"
},
content: "string",
createdAt: "string",
isSecret: "boolean",
userId: {
model: "user"
}
}
};
Inside the comment there are two nested model, User and Thread. But the response only shows the id
{
"comments": [
{
"threadId": 4,
"content": "Comment of thread one.",
"createdAt": "10-27-2016 09:39:50",
"isSecret": false,
"userId": 5,
"updatedAt": "2016-10-27T01:50:19.968Z",
"id": 3
}
],
"userId": {
"firstName": "Tio",
"LastName": "Ammar",
"email": "adityaamirullah@gmail.com",
"userName": "tioammar",
"avatar": "https://tioammar.com/avatar.jpg",
"createdAt": "2016-10-27T01:33:02.076Z",
"updatedAt": "2016-10-27T01:33:02.076Z",
"id": 5
},
"title": "Initial Thread",
"content": "Content of initial thread.",
"createdAt": "10-27-2016 09:34:50",
"isSecret": false,
"updatedAt": "2016-10-27T01:35:29.559Z",
"id": 4
}
I would like to show the actual User model. Please help and thanks in advance! :)