Add compatibility for @nestjs/mongoose
pilot22 opened this issue · 4 comments
Is your feature request related to a problem? Please describe.
The module cannot be used as of today on NestJS due to their port of mongoose which changes several things, starting with the connection to the database.
Describe the solution you'd like
Being able to use the ts-cache-mongoose on the @nestjs/mongoose port.
Additional context
Link to the module
NestJS documentation
Not sure, how heavily mongoose was modified by nestjs team but will take a look at their source code, and check what we can do about it.
Ok, there is nothing to do actually, you just use example, got my hands on nest today finally:
https://github.com/ilovepixelart/ts-express-nest
Okay, just tried your solution.
In fact it does work thanks to your Migration client that you have setup that registers your model directly through mongoose (https://github.com/ilovepixelart/ts-express-nest/blob/393447af21a9c45575644463a8fba3151ab96ff8/src/clients/migration.models.ts#L5)
So on my side, when using cache on models that aren't registered through regular mongoose, but through MongooseModule (nestjs module), I am getting the following exception:
MissingSchemaError: Schema hasn't been registered for model "xxx". Use mongoose.model(name, schema)
When registering through mongoose as you did, it does work.
It would be so nice that we wouldn't need to register manually our schema in mongoose in addition to all the nest verbosity for schema declaration. If the module could register/take note of the models on the fly thanks to the MongooseModule it would be perfect.