Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- adapted datastorage class to callback-semantics

  • Loading branch information...
commit 73a6825e468412bb964ae686a196a54c06245621 1 parent e4689c3
@dennisoelkers authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/datastorage.js
View
12 lib/datastorage.js
@@ -4,18 +4,18 @@ var DataStorage = function(config) {
this.server = new mongodb.Server(config['host'], config['port'], {});
this.db = new mongodb.Db(config['name'], this.server, {native_parser:true});
this.collection = config['collection'];
- this.db.open(function(err, db) {
- if(err) throw err;
- });
}
DataStorage.prototype.add = function(msg) {
//console.log('add() called');
//console.log('this.db: ' + this.db + ' this.collection: ' + this.collection);
var collection = this.collection;
- this.db.createCollection(collection, {}, function (err, c) {
- if (err) throw err;
- c.insert(msg);
+ this.db.open(function dataStorageOpenCallback(err, db) {
+ if(err) throw err;
+ db.createCollection(collection, {}, function dataStorageCreateCollectionCallback(err, c) {
+ if (err) throw err;
+ c.insert(msg);
+ });
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.