$limit
是你需要的。
限制 - http://docs.mongodb.org/manual/reference/method/cursor.limit/#cursor.limit
mongos> db.test.find()
{ "_id" : 1, "status" : "Failed" }
{ "_id" : 2, "status" : "Pass" }
{ "_id" : 3, "status" : "Failed" }
{ "_id" : 4, "status" : "Pass" }
{ "_id" : 5, "status" : "Failed" }
{ "_id" : 6, "status" : "Pass" }
{ "_id" : 7, "status" : "Failed" }
{ "_id" : 8, "status" : "Pass" }
{ "_id" : 9, "status" : "Failed" }
{ "_id" : 10, "status" : "Pass" }
mongos> db.test.find({status: "Failed"})
{ "_id" : 1, "status" : "Failed" }
{ "_id" : 3, "status" : "Failed" }
{ "_id" : 5, "status" : "Failed" }
{ "_id" : 7, "status" : "Failed" }
{ "_id" : 9, "status" : "Failed" }
mongos> db.test.find({status: "Failed"}).limit(3)
{ "_id" : 1, "status" : "Failed" }
{ "_id" : 3, "status" : "Failed" }
{ "_id" : 5, "status" : "Failed" }