Skip to content

Instantly share code, notes, and snippets.

@coderarity
Forked from zeromodulus/foo.js
Last active December 14, 2015 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderarity/5149306 to your computer and use it in GitHub Desktop.
Save coderarity/5149306 to your computer and use it in GitHub Desktop.
// (c) 2013 coderarity is a boss, inc
function Foo (id) {
var _this = this;
if (id) {
db.redis.get(id, function(err, res) {
var obj = JSON.parse(res);
for (property in obj) {
if (property === 'date_created') {
_this[property] = new Date(obj[property]);
} else {
_this[property] = obj[property];
}
console.log(_this[property]);
}
});
} else {
this.date_created = new Date();
this.id = createId(this.date_created.toString());
db.redis.set(this.id, JSON.stringify(this));
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment