#How to serialize Mongoose documents with class-transformer?

1 messages · Page 1 of 1 (latest)

visual leaf
#

Hi, I'm using Mongoose with NestJS and trying to serialize my documents in the response using class-transformer. The problem is that Mongoose doesn't return class instances, so class-transformer doesn't work as expected (e.g., @Expose() decorators are ignored).

What is the recommended way to properly serialize Mongoose documents so that they work with class-transformer? Is there a clean way to convert them to class instances before returning from a controller?

Any official or community best practice for this?

Thanks!

whole cedar