scott.mebberson.codes

MongoDB
Shell

MongoDB
Shell

db.collection.remove({query}, {options})

Remove records from a collection.

var collection = 'collection', field = 'field'; db[collection].distinct(field).forEach((val) => { print(`${field}, ${val}: ${db[collection].count({ [field]: val })}`) });

Count distinct field values.