I have this legacy code below using objection.js and I need to convert this to objection.js 3.
const result = await DeptClass.query()
.select(['employeerClass.label', 'employeerClass.description', 'employeerClass.id'])
.joinRelation('projectClasses')
.where('projectClasses.id', req.params.id)
.eager('depCodes(wccSelect).[state(stateSelect)]', {
wccSelect,
stateSelect
})
In their documentation, lots of methods have renamed. http://vincit.github.io/objection.js/release-notes/changelog.html#_2-0-0
For example,
joinRelation -> joinRelated,
eager -> withGraphFetched
So I came up with this code:
const result = await DeptClass.query()
.joinRelated('projectClasses')
.select('employeerClass.label', 'employeerClass.description', 'employeerClass.id')
.where('projectClasses.id', req.params.id)
.withGraphFetched('depCodes(wccSelect).[state(stateSelect)]', {
wccSelect,
stateSelect
})
However, when I run this code, the generated sql query is correct
but there is NO RESULT
and NO ERRORS
found.
Any idea what's wrong with this code?