title: How to update an array in Mongoose JS
body: <p>Currently, I'm trying to create a Discord bot that will save a to-do list in a database. To do so, I wanted to use an array that contains any items the person adds by typing <em>!listadd (something)</em> that will then be stored in a MongoDB database. However, while this seems to work for Strings, I cannot seem to change an array at all using this method.</p>
  <p><code>await list.findOneAndUpdate({_id: id},{$push:{todoList: msg}, itemToAdd:msg},{upsert : true})</code></p>
  <p>This line above is what I'm using to update the list. While the change to <strong>itemToAdd</strong> is reflected perfectly in the database, nothing is pushed to <strong>todoList</strong>. I can't even seem to update <strong>todoList</strong> at all past setting what the default value is in the schema. (Like, if I put <code>{todoList:['one','two']}</code> as the update object, it still won't do anything)</p>
  <p>I've tried using the <em>.updateOne()</em> method and, again, it works fine for <strong>itemToAdd</strong>, but nothing happens to <strong>todoList</strong>. I've also tried using the <em>.markModified()</em> method and I've either used it wrong or it isn't working here because, still, nothing changes in the database.</p>
  <p>Full Code:</p>
  <pre><code>const mongoose = require('mongoose');
  
  const todoSchema = new mongoose.Schema({
    todolist : [String],
    _id: {
      type : String,
      required : true
    },
    itemToAdd:{
      type: String,
      required: false
    },
    indexOfItemToRemove:{
      type: Number,
      required: false
    }
    
  });
  
  const list = mongoose.model('list', todoSchema);
  
  module.exports = async (client) =&gt; {
    client.on('message', async (message) =&gt; {
      const { author } = message;
      const { id } = author;
      const { bot } = author;
      if (!bot){
      console.log('AUTHOR:', author);
      if (message.content.includes('!listadd ')){
        const msg = message.content.substring(9)
          await list.findOneAndUpdate({_id: id},{$push:{todoList: msg}, itemToAdd:msg},{upsert : true})
        message.reply('Entry Added!')
    }
      if (message.content.includes('!listget')){
        let doc = await list.findOne({_id:id})
        message.reply(doc.itemToAdd)
      }
      }
    })
  }
  </code></pre>