Skip to content

Instantly share code, notes, and snippets.

@alexindigo
Last active December 25, 2015 14: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 alexindigo/6988693 to your computer and use it in GitHub Desktop.
Save alexindigo/6988693 to your computer and use it in GitHub Desktop.
// saves data to db
Chat.prototype.save = function Chat_save(channel, key, value, callback)
{
var _chat = this;
this._db.put(channel+':'+key, value, function(err)
{
if (err) return callback(err);
// update local
_chat[channel][key] = value;
return callback(null);
});
}
level(filename, {keyEncoding: 'utf8', valueEncoding: 'json'}, function(err, db)
{
if (err) return callback(err);
_chat._db = db;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment