objection.js: QueryBuilder.relate() and .patch() yield the wrong type
The typings have the relate()
method of QueryBuilder returning type this
and thus yielding a Model. However, relate()
actually yields either a numberor an object pairing IDs to their corresponding reference fields. I don’t know what the result is when providing multiple relations.
UPDATE: QueryBuilder patch()
has the same problem – should yield a number.
cc @mceachen
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 23 (9 by maintainers)
I hear from him once every day or two, which isn’t enough interaction for me to get this done. So I’m just doing it and he can look it over.
Maybe a separate issue should be opened for this
Query callbacks that don’t need to return anything:
modifyEager
where
callbacksselect
callbacksfrom
callbacksActually all subquery or where grouping callbacks don’t need to return anything and the return value and query builder return type are irrelevant.
If there are other callbacks, ask.
For now you can work around this by adding the
patch
orrelate
last.relate
typings cannot be fixed, an you need to use a cast.