var mongoose = require('mongoose')
    //
  , config = require('./config.js');

// ------------------------------------------------------------------------------------
// Action schema
// ------------------------------------------------------------------------------------

var schema = new mongoose.Schema({
  actionData: {
    //Schema.Types.Mixed
  },
  actionPlugin: {
    required: true,
    type: String
  },
  name: {
    required: true,
    type: String,
    unique: true
  },
  interval: {
    default: config.actionIntervalDelay,
    type: Number
  }
});

// ------------------------------------------------------------------------------------
// Static methods
// ------------------------------------------------------------------------------------

/**
 * list all actions
 * @param callback
 */

schema.statics.findAll = function(callback) {
  this.find({}, callback);
};

/**
 * find action by name
 * @param actionName
 * @param callback
 */

schema.statics.findByName = function(actionName, callback) {
  this.findOne({name: actionName}, callback);
};

// ------------------------------------------------------------------------------------
// Register our model
// ------------------------------------------------------------------------------------

module.exports = mongoose.model('Action', schema);

@@ -1,11 +1,42 @@
 var
+ moment = require('moment')%0A  ,
  mongoos
@@ -445,147 +445,218 @@
 ,%0A  
-name: %7B%0A    required: true,%0A    type: String,%0A    unique: true%0A  %7D,%0A  interval: %7B%0A    default: config.actionIntervalDelay,%0A    type: Number
+interval: %7B%0A    default: config.actionIntervalDelay,%0A    type: Number%0A  %7D,%0A  lastExecuted: %7B%0A    default: moment().valueOf(),%0A    type: Date%0A  %7D,%0A  name: %7B%0A    required: true,%0A    type: String,%0A    unique: true
 %0A  %7D

add lastExecuted