mail-time icon indicating copy to clipboard operation
mail-time copied to clipboard

Feature Request: Multiple options for data store

Open dekyfin opened this issue 6 years ago • 11 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 avatar Mar 08 '18 21:03 dekyfin

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

dr-dimitru avatar Mar 08 '18 21:03 dr-dimitru

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

mjurincic avatar Apr 24 '19 08:04 mjurincic

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

dr-dimitru avatar Apr 26 '19 09:04 dr-dimitru

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

edgedemon avatar Jul 11 '19 14:07 edgedemon

@edgedemon looks great! Want to discuss implementation steps?

dr-dimitru avatar Jul 13 '19 22:07 dr-dimitru

@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

edgedemon avatar Jul 14 '19 19:07 edgedemon

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 avatar Jul 15 '19 05:07 edgedemon

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.

edgedemon avatar Jul 15 '19 05:07 edgedemon

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.

dr-dimitru avatar Jul 16 '19 10:07 dr-dimitru

Would be nice to have other options.

lixaotec avatar Jul 21 '23 20:07 lixaotec