I am trying to insert an array to a schema that holds an array of strings but I get the same error every time:
const mongoose = require("mongoose");
const teamSchema = new mongoose.Schema({
  teamName: {
    type: String,
    required: true,
  },
  teamTeacher: {
    type: mongoose.Schema.Types.ObjectId,
    ref: "User",
  },
  isActive: {
    type: Boolean,
    default: true,
  },
  students: [{
   type: [mongoose.Schema.Types.ObjectId],
   ref: "student",
  }],
});
const Team = mongoose.model("Team", teamSchema);
const team1 = new Team({
  teamName: "team1",
  students: ["6451fe33cb3ca7242f39d2e7", "6451fe15cb3ca7242f39d2e2"],
  teamTeacher: "6450c60798100f4d0a7cffb3",
});
async function saveD() {
 await team1.save();
}
saveD();
console.log(team1);
I have tried every option possible for inverting the array of strings / numbers / objectId to the schema from the web with Postman via Visual Studio Code with promise and await the error is as follows:
this.$__.validationError = new ValidationError(this);
                               ^
ValidationError: Team validation failed: students: Cast to [undefined] failed for value "[]" (type string) at path "students.0" because of "TypeError", students.undefined: Cast to [undefined] failed for value "["6451fe33cb3ca7242f39d2e7","6451fe15cb3ca7242f39d2e2"]" (type string) at path "students.undefined" because of "TypeError"