veliovgroup / mail-time

📮 Email queue extending NodeMailer with multi SMTP transports and horizontally scaled applications support

Home Page:https://www.npmjs.com/package/mail-time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Multiple options for data store

dekyfin opened this issue · comments

It would be great if this plugin can use multiple data storage options such as (MySQL, redis-store, etc) in the future.

I wanted to integrate this plugin into my project. It's quite unfortunate I can't use it since the plugin is tightly coupled with MongoDB. My project uses MySQL for storing data; setting up and managing a Mongo Server only for the mail goes beyond the scope of the project

@dekyfin thank you for your feedback and suggestion.
We will consider it for the next releases. Suggestions are always welcome.

commented

This would make project easy portable to integrate into existing technology stacks, for solution which i RDBMS over MongoDB.

@mjurincic suggestions on unified API/solution to work with most of widely used DBs are always welcome here

i am thinking on using Sequelize to try this it should support most popular RDBMSs

@edgedemon looks great! Want to discuss implementation steps?

@dr-dimitru well i had a hammer so it looked a lot like a nail (that is to say its highly likely it can be improved).

i noticed your calls were using from your database handler 5 operations, findOne, findOneAndUpdate, insertOne, updateOne and deleteOne. So i made an interface following the pattern suggested by geedew guide, that way it could theoretically be enhanced to run with ANY data provider later, just extend the DataHandler and implement it with whatever your heart desires, right now in my fork:

  • i made an interface which requires to have those methods.

  • rewrote the queries inside the index.js to reference the interface instead of a mongodb collection,

  • made a mongodb implementation, and one for sequelize.

  • made sure the module formats into mongodb implementation in case what it gets is not any kind of implementation for retrocompatibility.

so far it passes all the tests but i admit i haven't tested it in-depth.

P.D.: i would suggest to make the test use Sinnon to remove the dependency for mongodb for testing

taking another look it wont work as i wished since you are using josk for the queue system, i would need to replace it or modify it in a non trivial way.

for my current project i think i'll make a Redis Data Handler and modify the queue to use Bull, instead but exporting the queue into another component could be an interesting project for later.

taking another look it wont work as i wished since you are using josk for the queue system, i would need to replace it or modify it in a non trivial way.

@edgedemon feel free to apply the same idea to josk package, I would be happy to accept same PR to josk repository.

Would be nice to have other options.

@dekyfin @mjurincic @edgedemon @lixaotec 📦 v3.0.0 with support of Redis and Custom Queue storage is out!