reading crontab from db done

This commit is contained in:
Suresh Alse
2015-06-12 00:51:59 +05:30
parent 9dd4c607d0
commit 4700ddb4a5
8 changed files with 116 additions and 55 deletions

29
crontab.js Normal file
View File

@@ -0,0 +1,29 @@
//load database
var Datastore = require('nedb');
var db = new Datastore({ filename: __dirname + '/crontabs/crontab.db' });
db.loadDatabase(function (err) {
});
crontab = function(command, schedule, stopped){
var data = {};
data.command = command;
data.schedule = schedule;
data.stopped = stopped;
data.timestamp = (new Date()).toString();
return data;
}
exports.create_new = function(command, schedule){
var tab = crontab(command, schedule, false);
db.insert(tab);
}
exports.crontabs = function(callback){
var finished = false;
db.find({}, function(err, docs){
finished = true;
callback(docs);
});
}