I have 2 models. One is an Article (content, category)
, and the other is Category (id, name)
.
In Article I have defined relation to Category.
"categories": {
"type": "hasOne",
"model": "Category",
"foreignKey": "category"
}
I insert new Product with category id in category field.
Now, when I get the Articles over REST API I would like to receive category name instead of category Id. I wanted to figure it out based on documentation, but failed.
I use MySQL relational DB.
How can I achieve that?
You need to use the include filter https://docs.strongloop.com/display/public/LB/Include+filter
In your case:
/articles?filter[include]=categories