Jump to content

Multiplayer Mongodb Socket.io


azurazen
 Share

Recommended Posts

Im trying to use socket.io with a game im working on and cant seem to get mongodb to play nice with it. This is most likely due to my never having used mongo before, though socket.io seems pretty straight forward... 

Currently im having issues with separating the two to make a more manageable codebase to work with, but seem to keep getting hung up on waiting for mongodb to retrieve the documents..

Is there anyway to retrieve info from mongodb without having to do the following

var mongo = require('mongodb');
 
var url = "url";//url
 
mongo.connect(url,function(err,db){
if (err) throw err;
dbAladdin = db.db("Aladdin");
 
console.log("Database Opened!");
 
armsman = dbAladdin.collection("skills").findOne({}, function(err, result) {
if (err) throw err;
// Can only access result here
});
 
// Cannot get result here?
});
// Or Here
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...