Jump to content

Multiplayer Mongodb Socket.io


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
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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