title: How to create subdocument on mongodb dynamically
body: <p>I have a mongodb database with a collection as follow: </p>
  
  <pre><code>var mongoose = require('mongoose');
  var journalSchema = mongoose.Schema({
    title : String,
    journalid: {type:String, index: { unique: true, dropDups: true }},
    articleCount : type:Number, default:1,
  });
  module.exports = mongoose.model('Journal', journalSchema);
  </code></pre>
  
  <p>Now that my database is growing, I would like to have a "articles count" field <strong>per year</strong>.</p>
  
  <p>I could make an array as follow <code>years : [{articleCount : Number}]</code> and fill it up by accessing <code>journal.years[X]</code> for a specific year, where X correspond to 0 for 1997, 1 for 1998, etc..</p>
  
  <p>However, my data are scrapped dynamically and I would like to have a function in my express server where <code>articleCount</code>is increased based on the year.</p>
  
  <p>For example:</p>
  
  <pre><code>function updateYear(journalid, year, callback) {
    Journal.findOneAndUpdate(
      {'journalid':journalid},
      {$inc : {'articleCount' : 1}}, // DO SOMETHING WITH year HERE
      function() {
        callback();
      });
  }
  </code></pre>
  
  <p>This does increase the article count but I don't know where to include the "year"...</p>
  
  <p>What would be the fastest way of doing that, knowing that I have to fetch through quite a lot of articles (10 millions +) and I would like to be able to get/update the article count for a given year efficiently.</p>
  
  <p>Hope I'm clear enough, Thanks!</p>