title: Is my Mongoose Schema incorrect?
body: <p>I believe my Mongoose Schema must be incorrect, because my DB is not updated correctly when I use .save() in Mongoose. After the below nodeJS route runs, the updated Object I received in the callback is correct, but on subsequent runs, the DB object is empty, and was never updated.</p>
  
  <p>Here is an example of what my data will look like:</p>
  
  <pre><code>      var newApplicationData = new ApplicationData({
          pos1: 0,
          pos2: 0,
          applicationData: [
  
              // Standard One
              {
                  sections: [
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      }
                  ]
              },
  
              // Standard 2
              {
                  sections: [
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      }
                  ]
              },
  
              // Standard 3
              {
                  sections: [
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      }
                  ]
              },
  
              // Standard 4
              {
                  sections: [
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      },
                      {
                          narrative: '',
                          documentation: []
                      }
                  ]
              },
          ]
      });
  </code></pre>
  
  <p>Now here is my Mongoose Schema:</p>
  
  <pre><code>const mongoose = require('mongoose');
  
  const ApplicationDataSchema = mongoose.Schema({
  pos1: {
      type: Number, 
      required: true,
  },
  pos2: {
      type: Number,
      required: true,
  },
  applicationData: {
      type: Array,
      required: true,
  
      sections: {
          type: Array,
          required: true,
  
          narrative: {
              type: String,
              required: true
          },
          documentation: {
              type: Array,
              required: true
          }
      }
  }
  }, { collection : 'applicationData' });
  
  const ApplicationData = module.exports = mongoose.model('ApplicationData', ApplicationDataSchema);
  </code></pre>
  
  <p>And finally, here is my NodeJS route where I am trying to save data using .save():</p>
  
  <pre><code>app.post('/upload', multer({ storage: storage }).single('file'), (req, res) =&gt; {
  
      if(!req.file) return res.send({ status: 400, msg: 'No File Received.' });
  
      let pos1 = req.body.pos1;
      let pos2 = req.body.pos2;
  
      ApplicationData.findById(mongoose.Types.ObjectId(req.body.applicationDataID), (err, applicationDataObject) =&gt; {
  
        if(err) return res.send({ status: 400, msg: err });
  
        applicationDataObject.applicationData[pos1].sections[pos2].documentation.push(req.file.filename);
  
        applicationDataObject.save((err, updatedApplicationData) =&gt; {
  
          console.log(applicationDataObject.applicationData[pos1].sections[pos2].documentation);
  
          if(err) return res.send({ status: 400, msg: err });
  
          return res.send({ status: 200, applicationData: updatedApplicationData.applicationData });
        });
      });
  });
  </code></pre>