needle-innovision / nestjs-tenancy

Multi-tenancy approach for nestjs - currently supported only for mongodb with mongoose
MIT License
186 stars 58 forks source link

Lifecycle Events and Task Scheduling not working #43

Closed canhhungit closed 1 year ago

canhhungit commented 1 year ago

Hi @sandeepsuvit ,

I changed MongooseModule to TenancyModule then i got warning like this.

Task Scheduling and onModuleInit not working. Please check

image

canhhungit commented 1 year ago

Project to test proplem

https://github.com/canhhungit/NestJS-tenancy

sandeepsuvit commented 1 year ago

@canhhungit thanks for writing in. I checked your code. Seems like you are using a cron trigger inside your service class. The way the library is designed and the tenant is resolved is via a Request scoped object that comes from the client applications. In case of cron triggers they are originated from the backend application itself and not via a client side request. Hence there is no way the module can understand and resolve the correct tenant schema model. I am guessing for this cron cases the connections needs to be manually resolved and used.

canhhungit commented 1 year ago

Thank you @sandeepsuvit. While waiting from your response, i understand proplem as you said. I resolve it menual with connection string with monggose

sandeepsuvit commented 1 year ago

@canhhungit thats great and sorry for the delayed response :)