diff --git a/models.json b/models.json index 0a6fd45..d1d94ec 100644 --- a/models.json +++ b/models.json @@ -15,8 +15,7 @@ "default": false }, "created": { - "type": "number", - "//default": "//TODO: Date.now" + "type": "number" } }, "dataSource": "db" diff --git a/models/todo.js b/models/todo.js index 298d181..583b27f 100644 --- a/models/todo.js +++ b/models/todo.js @@ -4,6 +4,8 @@ var async = require('async'); module.exports = function(app) { var Todo = app.models.Todo; + Todo.definition.properties.created.default = Date.now; + Todo.beforeSave = function(next, model) { if (!model.id) model.id = 't-' + Math.floor(Math.random() * 10000).toString(); next();