Difference between find and findOne
mongodb
Solution
`findOne` returns a single document, where `find` returns a cursor. Once you go through the cursor of `find`, you are at the end, and there are no more documents.
Problem
when a variable say testVar is assigned with result of findOne, its availability is endless. But a variable assigned with result of find() availability is only once. Below is the command prompt dump ``` > var testVar = db.basic.findOne() > testVar { "_id" : ObjectId("52abd2737164a542e93f1ebe"), "name" : "MongoDB" } > testVar { "_id" : ObjectId("52abd2737164a542e93f1ebe"), "name" : "MongoDB" } > testVar { "_id" : ObjectId("52abd2737164a542e93f1ebe"), "name" : "MongoDB" } > var testVar = db.basic.find({"name":"MongoDB"}) > testVar { "_id" : ObjectId("52abd2737164a542e93f1ebe"), "name" : "MongoDB" } > testVar > testVar > ```