count number of documents in mongodb code example Example: mongo count db.collection.countDocuments( <query>, <options> )