-
Notifications
You must be signed in to change notification settings - Fork 642
Closed
Description
I have a subselect that returns multiple rows.
To get the values out of the DB, I need to wrap the subselect in ARRAY().
There doesn't seem to be a way to achieve this without writing a raw query.
My use case is only a small variation on example http://vincit.github.io/objection.js/#getting-count-of-relations
e.g
const tweets = await Tweet
.query()
.select(
'Tweet.*',
raw('ARRAY(?)', Tweet.relatedQuery('likers').select('id')).as('likerIds')
);
console.log(tweets[4].likeIds);
Any advice @koskimas ?
Metadata
Metadata
Assignees
Labels
No labels