Browse Source

Final cleanup of Nodejs for v0.12 bump

Edward Bramanti 10 years ago
parent
commit
f5688f199d
1 changed files with 11 additions and 6 deletions
  1. 11 6
      frameworks/JavaScript/nodejs/hello.js

+ 11 - 6
frameworks/JavaScript/nodejs/hello.js

@@ -10,22 +10,25 @@ var cluster = require('cluster')
   , mysql = require('mysql')
   , mysql = require('mysql')
   , async = require('async')
   , async = require('async')
   , mongoose = require('mongoose')
   , mongoose = require('mongoose')
-  , conn = mongoose.connect('mongodb://127.0.0.1/hello_world')
+  , conn = mongoose.connect('mongodb://localhost/hello_world')
   , MongoClient = require('mongodb').MongoClient;
   , MongoClient = require('mongodb').MongoClient;
 
 
+// MongoDB Raw Setup
 var collection = null;
 var collection = null;
-MongoClient.connect('mongodb://127.0.0.1/hello_world?maxPoolSize=5', function(err, db) {
+MongoClient.connect('mongodb://localhost/hello_world?maxPoolSize=5', function(err, db) {
   collection = db.collection('world');
   collection = db.collection('world');
 });
 });
 
 
+// MySQL Raw Setup
 var connection = mysql.createConnection({
 var connection = mysql.createConnection({
-  host     : '127.0.0.1',
+  host     : 'localhost',
   user     : 'benchmarkdbuser',
   user     : 'benchmarkdbuser',
   password : 'benchmarkdbpass',
   password : 'benchmarkdbpass',
   database : 'hello_world'
   database : 'hello_world'
 });
 });
 connection.connect();
 connection.connect();
 
 
+// Mongoose Setup
 var WorldSchema = new mongoose.Schema({
 var WorldSchema = new mongoose.Schema({
     id          : Number,
     id          : Number,
     randomNumber: Number
     randomNumber: Number
@@ -34,8 +37,9 @@ var WorldSchema = new mongoose.Schema({
   }),
   }),
   MWorld = conn.model('World', WorldSchema);
   MWorld = conn.model('World', WorldSchema);
 
 
+// Sequelize Setup
 var sequelize = new Sequelize('hello_world', 'benchmarkdbuser', 'benchmarkdbpass', {
 var sequelize = new Sequelize('hello_world', 'benchmarkdbuser', 'benchmarkdbpass', {
-  host: '127.0.0.1',
+  host: 'localhost',
   dialect: 'mysql',
   dialect: 'mysql',
   logging: false,
   logging: false,
   pool: {
   pool: {
@@ -87,6 +91,7 @@ function mongodbDriverQuery(callback) {
   collection.findOne({
   collection.findOne({
     id: getRandomNumber()
     id: getRandomNumber()
   }, function(err, world) {
   }, function(err, world) {
+    world._id = undefined; // remove _id from query response
     callback(err, world);
     callback(err, world);
   });
   });
 }
 }
@@ -97,8 +102,8 @@ function mongodbDriverUpdateQuery(callback) {
   }, [['_id','asc']], {
   }, [['_id','asc']], {
     $set: {randomNumber: getRandomNumber()}
     $set: {randomNumber: getRandomNumber()}
   }, {}, function(err, world) {
   }, {}, function(err, world) {
-    world._id = undefined; // remove _id from query response
-    callback(err, world);
+    world.value._id = undefined; // remove _id from query response
+    callback(err, world.value);
   });
   });
 }
 }