Sample Header Ad - 728x90

How to parse MongoDB int32 in node.js

0 votes
1 answer
378 views
I am using MongoDB for a discord bot I am working on, and I want to retrieve a user's balance. My current code is `function findBalance(id){ MongoClient.connect(url, function(err, db) { if (err) throw err; var dbo = db.db("DiscordDB"); var query = { uuid: id }; dbo.collection("players").find(query).toArray(function(err, result) { if (err) throw err; console.log(result.balance); db.close(); }); }); }`. When I call the function it returns undefined... any thoughts?
Asked by woofymax (1 rep)
Jun 21, 2020, 06:33 AM
Last activity: Mar 2, 2025, 11:00 AM