Time stamp plugin to support creating timestamp

Example
//initialize default timestamp functionality
var MyModel = patio.addModel("testTable", {
    plugins : [patio.plugins.TimeStampPlugin],

    static : {
        init : function(){
            this._super("arguments");
            this.timestamp();
        }
    }
});



//custom updated column
var MyModel = patio.addModel("testTable", {
    plugins : [patio.plugins.TimeStampPlugin],

    static : {
        init : function(){
            this._super("arguments");
            this.timestamp({updated : "myUpdatedColumn"});
        }
    }
});

//custom created column
var MyModel = patio.addModel("testTable", {
    plugins : [patio.plugins.TimeStampPlugin],

    static : {
        init : function(){
            this._super("arguments");
            this.timestamp({created : "customCreatedColumn"});
        }
    }
});

//set both custom columns
var MyModel = patio.addModel("testTable", {
    plugins : [patio.plugins.TimeStampPlugin],

    static : {
        init : function(){
            this._super("arguments");
            this.timestamp({created : "customCreatedColumn", updated : "myUpdatedColumn"});
        }
    }
});

//Set to update the updated column when row is created
var MyModel = patio.addModel("testTable", {
    plugins : [patio.plugins.TimeStampPlugin],

    static : {
        init : function(){
            this._super("arguments");
            this.timestamp({updateOnCreate : true});
        }
    }
});

//Set all three options
var MyModel = patio.addModel("testTable", {
    plugins : [patio.plugins.TimeStampPlugin],

    static : {
        init : function(){
            this._super("arguments");
            this.timestamp({created : "customCreatedColumn", updated : "myUpdatedColumn", updateOnCreate : true});
        }
    }
});
            

Constructor

Defined plugins/timestamp.js Source
exports = define(null, {
            

timestamp Static Function Public


Defined plugins/timestamp.js

Adds timestamp functionality to a table.

Arguments Source
function (options){
   options = options || {};
   this._timestampOptions = options;
   var updateColumn = options.updated || "updated";
   var createdColumn = options.created || "created";
   var updateOnCreate = options.updateOnCreate || false;
   this.pre("save", function (next) {
       this[createdColumn] = new Date();
       if (updateOnCreate) {
           this[updateColumn] = new Date();
       }
       next();
   });
   this.pre("update", function (next) {
       this[updateColumn] = new Date();
       next();
   });
   return this;
           
}
    

Documentation generated using coddoc.