Hi all, i'm starting to work with Erlang and CB, and i'm building a RESTful api, and i have a question about how to build the json to access data from one model to another
My model and my controller looks like this:
%% review model
-module(review,
[
Id,
UsersId,
Score::integer(),
Speed::integer(),
Comment::string(),
Date::datetime()
]
).
-compile(export_all).
-belongs_to(users).
%% users model
-module(users,
[
Id,
FirstName::string(),
LastName::string(),
Email::string()
]
).
-compile(export_all).
-has({reviews, many}).
%% my review controller:
api('GET', [Id]) ->
Review = boss_db:find(Id),
case Review of
Review ->
{json, [{review, Review}]};
[] ->
not_found
end;
%% and my current json is as follows
[{
"id":"review-1",
"users_id":"users-1",
"score":1,
"speed":1,
"comment":"foo",
"date":"February 07, 2014 21:52:53",
}]
and my question is how to access the data from the "users-1"
Thank you very much, and sorry for the length of the message