nestjs / mongoose

Mongoose module for Nest framework (node.js) 🍸
https://nestjs.com
MIT License
528 stars 118 forks source link

Mongoose type generator #609

Closed SasanFarrokh closed 4 years ago

SasanFarrokh commented 4 years ago

5 I'm submitting a suggestion to deal with mongoose typings

Current behavior

We're trying to make a schema out of decorated typescript class, nestjs developed a package for it, like typegoose did. But the thing is mongoose is not typescript friendly and i think it's so much easier to create the schema in the mongoose way.

What i'm suggesting is to switch to mongoose schema first approach then generate the typings out of the schema.

What is the motivation / use case for changing the behavior?

Currently statics are not supported with this current approach. And also generating is fun, like the graphql schema first approach is.

here is a minimal example i tried to write for the mongoose type generating:

https://github.com/SasanFarrokh/mongoose-type-gen

kamilmysliwiec commented 4 years ago

Hey @SasanFarrokh! Unfortunately, generating TS typings based on mongoose schemas isn't something on our radar at the moment. We don't plan to add this feature in the near future.