how to add field total and attach the total number of document in mongodb code example Example: mongo count db.collection.countDocuments( <query>, <options> )