There are two tables users and activities.
I am able to join these using withGraphJoined. The response json is like this,
[
{
user: 'first',
activity: [{ type: 'act1' }, { type: 'act2' }],
},
{
user: 'second',
activity: [{ type: 'act3' }, { type: 'act2' }],
},
];
Now i want to fetch only the first activity and make current array into first activity object. {user:"second", activity:{type:"act3}}
I tried this but still i get all the activity in array.
User.query()
.withGraphJoined('activity')
.modifyGraph('activity', (builder) => builder.first());