Closed yalcinozer closed 6 months ago
@yalcinozer
TL;DR
using lean
is a good solution, and should be use like this at least.
otherwise you can wrap the data into a interface to explicitly defines the return type.
If you did not to do so.
tsoa will try to infer the type by resolving object gives after return
.
In your case, after query the schema, the return type would be mongoose.Document,
which contains the type Omit<any, any>
that tsoa cannot resolve causing this error.
With lean()
function, mongoose will transform the Document object to plain object, which tsoa can resolve it.
About Omit<any, any>
, in actually can consider as an issue, but currently I think its not causing people bothering , YET.
Directly return the database object is not a prefer, wrapping data into concrete interface is the responsibility of developers using tsoa.
@yalcinozer If there is no more concerns, Can you close this issue? thx.
Of course. I am not too familiar with the process, was expecting you might do it, thanks. It resolved for now.
I have a students field and it is an object of arrays. One of the field is ObjectId and referenced to another collection. The endpoint populates and returns the data even if command line logs error. And this behaviour is not exclusive to this model, happens in others if they have some structure. I am open to take any support If I am making mistakes. Thanks.
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
It shouldn't log any errors.
Current Behavior
Possible Solution
I realised error logs disappears if I do one of two things below:
Context (Environment)
Version of the library: 5.1.1 Version of NodeJS: v18.17.0