Skip to content

Instantly share code, notes, and snippets.

@zeromodulus
Created March 13, 2013 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zeromodulus/5149283 to your computer and use it in GitHub Desktop.
Save zeromodulus/5149283 to your computer and use it in GitHub Desktop.
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