How to fix MongoError: Cannot use a session that has ended
问题 I'm trying to read data from a MongoDB Atlas collection using Node.js. When I try to read the contents of my collection I get the error MongoError: Cannot use a session that has ended . Here is my code client.connect(err => { const collection = client .db("sample_airbnb") .collection("listingsAndReviews"); const test = collection.find({}).toArray((err, result) => { if (err) throw err; }); client.close(); }); I'm able to query for a specific document, but I'm not sure how to return all