#How to allow access to DB in service for daily mail sender function with @Cron || @Interval

7 messages · Page 1 of 1 (latest)

tribal trail
#

Hello, I have a task to send daily mails with some information. Information need to be taken from DB but
I receive errors like in terminal, UserService is undefined.

faint moon
#

you're missing the @Injectable decorator over DailyMailService, so Nest doesn't see any metadata about what to inject.

tribal trail
#

Next error when I add @Injectable. Where I need to add this UserService. I have it in dailyMail.module.ts (second picture)

faint moon
#

Do not put services in multiple providers array in multiple modules. Nest will try to create a new instance every time you do. Instead export the providers and import the module which exports the provider in the module where it is needed.

tribal trail
#

So right now I remove dailyModule and I put dailyService in in ServiceModule and I create my method in UsersService to be with @Inteval(100) for testing but right now i receive warning.WARN [Scheduler] Cannot register interval "UserService@TestMailSender" because it is defined in a non static provider. How i can fix this. I try to found something in WEB but .. :/

faint moon
#

Nonstatic provider means it is transitively request-scoped

tribal trail
#

Ok but how I can fix it ;/