Skip to content

Instantly share code, notes, and snippets.

@alexindigo
Created October 15, 2013 10:11
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 alexindigo/6989450 to your computer and use it in GitHub Desktop.
Save alexindigo/6989450 to your computer and use it in GitHub Desktop.
[ 'saved',
595869639309040,
'{"time":1381831832149,"user":"_admin_admin","text":"new message","id":595869639309040}' ]
[ 'loaded',
595869639309040,
{ time: 1381831832149,
user: '_admin_admin',
text: 'new message',
id: 595869639309040 } ]
// saves data to db
Chat.prototype.save = function Chat_save(channel, key, value, callback)
{
var _chat = this;
this._db.put(token[channel]+':'+key, value, function(err)
{
if (err) return callback(err);
console.log(['saved', key, JSON.stringify(value)]);
_chat._db.get(token[channel]+':'+key, function(err, value)
{
console.log(['loaded', key, value]);
});
// update local
_chat[channel][key] = value;
return callback(null);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment