Replies: 1 comment
-
This is how I might write the controller endpoint to utilize the explicit DTO: public async index ({ request }): Promise<GameResponse[]> {
return await Game.query()
.orderBy('created_at', 'desc')
.paginate(requestGet.page, requestGet.limit)
.select('id', 'appid', 'name', 'createdAt', 'updatedAt');
} Not 100% on if there will be type errors there, but by declaring the return type of the function to be of your DTO type, you'll get type checking on that. Then, (and this is the part I'm not 100% on) if you specify only the columns of your DTO to select from the query, it should be able to infer the return type. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Our team try to use dto in adonisjs now,
But there are some problems.
and push query res data into the class every time:
This is very tedious and pushes repeatedly for each query.
We open-source the code now:
Beta Was this translation helpful? Give feedback.
All reactions