-
-
Save coderarity/5149306 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
// (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