Open almeynman opened 8 years ago
Hello,
Suppose I have a model Player:
const Player = thinky.createModel('Player', { email: type.string().email(), password: type.string() });
And I have a relationships:
Player.hasMany(Game, 'hostedGames', 'id', 'hostId'); Player.hasAndBelongsToMany(Game, 'visitedGames', 'id', 'id', {type: 'visitedGames'});
So now response is going to look like:
{ email: 'johndoe@gmail.com', password: 'aasdsa', hostedGames: [...], visitedGames: [...] }
But what If I want is for the relational fields to be nested, i.e.:
{ email: 'johndoe@gmail.com', password: 'aasdsa', football: { hostedGames: [...], visitedGames: [...] } }
Is it possible to define relationship, so that they will be nested in some object with thinky?
Thanks
This is currently not possible. Joined documents have to lie on the top level. This prevents weird/undesired edge cases like if football contains other fields, things get complicated.
football
Hello,
Suppose I have a model Player:
And I have a relationships:
So now response is going to look like:
But what If I want is for the relational fields to be nested, i.e.:
Is it possible to define relationship, so that they will be nested in some object with thinky?
Thanks