azurazen Posted April 30, 2018 Share Posted April 30, 2018 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 More sharing options...
theNeedle Posted May 6, 2018 Share Posted May 6, 2018 you might consider using Mongoose ODM. I think it would be easier(and better) than directly using mongodb. Link to comment Share on other sites More sharing options...
Recommended Posts