title: Mongoose: cast to array failed for value "[ 5ac5cfb41fca8a22f519cb22 ]"
body: <p>I am trying to insert a round in a existing game, which gives me the following error:</p>
  
  <blockquote>
    <p>Game validation failed: rounds.1.questions: Cast to Array failed for value "[ 5ac5cfb41fca8a22f519cb22 ]" at path "questions"</p>
  </blockquote>
  
  <p>Schema's: </p>
  
  <pre><code>const roundSchema = Schema({
    roundNumber: {
      type: Number,
      required: true,
    },
    categories: {
      type: [String],
      required: true
    },
    questions: {
      type: [Schema.Types.ObjectID],
      ref: 'Question',
      required: true,
    }
  });
  
  const gameSchema = Schema({
    code: {
      type: String,
      required: true,
    },
    teams: {
      type: [Schema.Types.ObjectID],
      required: false,
    },
    rounds: [roundSchema]
  });
  
  const questionSchema = Schema({
    question: {
      type: String,
      required: true,
    },
    answer: {
      type: String,
      required: true,
    },
    category: {
      type: String,
      required: true,
    }
  });
  </code></pre>
  
  <p>insert function:</p>
  
  <pre><code>function createRoundForGame(game, round) {
    round.questions = round.questions.map((question) =&gt; {
      return mongoose.Types.ObjectId(question);
    });
  
    console.log(round.questions);
    game.rounds.push(round);
  
    return game.save()
  }
  </code></pre>
  
  <p>Parameter game is: </p>
  
  <pre><code>{ 
     teams: [],
     rounds: 
      [ { categories: [Array],
          questions: [],
          _id: 5ac7507c5491ed422de3ce68,
          roundNumber: 1 } ],
     _id: 5ac74cccc65aac3e0c4b6cde,
     code: '537epG',
     __v: 1 
  }
  </code></pre>
  
  <p>Parameter round is:</p>
  
  <pre><code>{ 
     roundNumber: 1,
     questions: [ '5ac5cfb41fca8a22f519cb22' ],
     categories: [ 'Art and Literature', 'Music', 'Science and Nature' ] 
  }
  </code></pre>
  
  <p>console.log(round.questions) result :</p>
  
  <pre><code>[ 5ac5cfb41fca8a22f519cb22 ]
  </code></pre>
  
  <p>mongoose : 5.0.12,</p>
  
  <p>I have no idea what i am doing wrong here. And would appreciate some help here.</p>