Created
March 2, 2016 02:57
-
-
Save greduan/a1d90023e86857c0491e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var uuid = require('node-uuid') | |
var M = {} | |
M.BaseModel = Class(M, 'BaseModel').inherits(Krypton.Model)({ | |
primaryKey: 'uuid', | |
prototype: { | |
init: function (config) { | |
Krypton.Model.prototype.init.call(this, config) | |
var that = this | |
this.on('onBeforeCreate', function (next) { | |
var buffer = new Buffer(16) | |
uuid.v4(null, buffer) | |
that.uuid = uuid.unparse(buffer) | |
return next() | |
}) | |
}, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment