Since id is the primary key of an model, we shouldn't return an array from an query like this
const client = await Client.query()
.where('id', request.auth.credentials.userId)
the id is unique, why not return the object instead of an array?
The same behavior should append with unique columns using objection-unique
Why should Objection make such smart assumption on user's behalf and surprise him with inconsistent behaviour?
You can always use .first() explicitly.
@Ahlid To add to @kibertoad you can also use:
const client = await Client.query()
.findOne('id', request.auth.credentials.userId)
thanks alot @heisian =)
findOne also lead me to findById that has the behavior I wanted