rethink/couch db manual trigger and executing a script

187 views Asked by At

I am working on a project where I have to send a campaign mail to the users on specific date and time.

Technology : Node, Rethinkdb/Couchdb

Please do not suggest a cron job.

What I have thought to use : I will be using a custom trigger where db will fires an event by checking the current date with the saved campaign dates(start date and end date). And if it matches with the campaign date(i.e. current date between start date and end date), I will run the nodejs script to send a mail.

So is there any feature/functionality that couchdb/rethinkdb provides for manual triggering which can check the values in db and based on that can execute a script?

Or any other solution for this?

Thanks in advance.

2

There are 2 answers

0
pravindot17 On BEST ANSWER

I found a work around on this. I used a node schedule module to execute script for sending a mail. In this, the problem I was facing that whenever the server was restarting the cron was getting flushed, so I created them every time the server was restarting by putting them in mongodb.

0
Jan Lehnardt On

Databases don’t usually do this kind of thing. CouchDB definitely does not have this functionality.

However, with CouchDB you can build it fairly easily using the _changes feed: http://docs.couchdb.org/en/2.0.0/api/database/changes.html — that way your script can listen for any data updates and act according to whatever criteria you define, including time.