summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Fridman <fridman@mail.sfsu.edu>2015-05-13 13:06:51 -0400
committerSean Fridman <fridman@mail.sfsu.edu>2015-05-13 13:06:51 -0400
commitf0dffd39f92c64b17e0f44468757f4b199c1981b (patch)
tree79818d83d9326c5a5bbc0c300bc47f1a9875a835
parent4ebff1d371a6ddbf164aa29083ef00a9dfdc7895 (diff)
Store dateCreated on new resources
-rw-r--r--app/index.js3
-rw-r--r--app/node_modules/okdb/index.js3
2 files changed, 6 insertions, 0 deletions
diff --git a/app/index.js b/app/index.js
index 2de4f1b..963bfd0 100644
--- a/app/index.js
+++ b/app/index.js
@@ -118,7 +118,10 @@ OKCMS.prototype._createSchemas = function(schemaConfig) {
return Object.keys(schemaConfig).reduce(function(cache, key) {
var spec = schemaConfig[key];
// All resources have an autoincrementing index so we can order them suckas
+ // TODO Screw the __ prefix, just consider 'index' a reserved word
spec.__index = {type: 'meta', autoincrement: true};
+ // All resources have a dateCreated field
+ spec.dateCreated = {type: 'meta'};
cache[key] = OKSchema(spec);
return cache;
}, {});
diff --git a/app/node_modules/okdb/index.js b/app/node_modules/okdb/index.js
index 5aa22a2..4820c8c 100644
--- a/app/node_modules/okdb/index.js
+++ b/app/node_modules/okdb/index.js
@@ -68,6 +68,9 @@ FSDB.prototype.insert = function(collection, data) {
data = cloneDeep(data);
// Auto-increment fields
data = autoincrement(wrapped, schema, data);
+ // Record date created
+ // TODO Should this meta prop logic be moved out of the DB?
+ data.dateCreated = new Date().toUTCString();
var result = wrapped.chain().push(data).last().value();
if (result) {