MongoDB find() and count() returning different number of documents

Viewed 96

I am running a simple find() query in a sharded MongoDB cluster (through a mongos instance) mongo shell:

mongos> db.widgets.find({"_id" : ObjectId("53b76d2569702d63bb670000")}).count()
    
mongos> db.widgets.find({"_id" : ObjectId("53b76d2569702d63bb670000")})
    
{
  "_id" : ObjectId("53b76d2569702d63bb670000"),
  "page_id" : ObjectId("53b76d2569702d63bb660000"),
  "user_id" : ObjectId("53a012fc69702d69ebc50200"),
  "updated_at" : ISODate("2014-07-05T03:12:37.279Z"),
  "created_at" : ISODate("2014-07-05T03:12:37.279Z")
}

mongos> it
no cursor
mongos>

As you can see, find().count() returns 2, but find() only returns one document. And there is no cursor to iterate.

What would be the reason for this discrepancy?

Thank you.

0 Answers
Related