Count occurrences of duplicate values
<p>How do I structure my MongooseJS/MongoDB query to get total duplicates/occurrences of a particular field value? Aka: The total documents with <code>custID</code> of <code>some value</code> for all custIDs</p>

<p>I can do this manually in command line:</p>

<p><code>db.tapwiser.find({"custID" : "12345"}, {}, {}).count();</code></p>

<p>Outputs: 1</p>

<p><code>db.tapwiser.find({"custID" : "6789"}, {}, {}).count();</code></p>

<p>Outputs: 4</p>

<hr>

<p>I found this resource:</p>

<p><a href="https://stackoverflow.com/questions/27213284/how-to-sum-distinct-values-of-a-field-in-a-mongodb-collection-utilizing-mongoos">How to sum distinct values of a field in a MongoDB collection (utilizing mongoose)</a></p>

<p>But it requires that I specify the unique fields I want to sum.</p>

<p>In this case, I want to loop through all documents, sum the occurrences of each.</p>