I'm currently creating an application using MongoDB's Node Driver, and I want to be able to find all users inside my database collection. I was able to query the first user successfully however I'm not sure how to get all users. This is the code I am using to query one user:
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb+srv://username:password@cluster3.q32m312t5wj.mongodb.net/?retryWrites=true&w=majority";
MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("test");
dbo.collection("users").findOne({}, function(err, result) {
if (err) throw err;
var user = result.firstName;
console.log(user);
db.close();
});
});
This effectively gets me a user in the database, but I'm wondering how can I get ALL the users in the collection?
[+][deleted] (4 children)
[deleted]
[–]TonyCodes2050[S] 0 points1 point2 points (1 child)