Product with different varients schema

I am trying to implement a Product Schema I’ve found here.

But whenever I try to insert a product into it, I face this error, can you help me ?

// 20211212105849 // http://localhost:5000/api/products/seed

{ "message": "Product validation failed: subcategory.0: Cast to [string] failed for value "[{"type":"slimline","model":[{"type":"twill","colour":[{"name":"red","image":"red.jpg"},{"name":"white","image":"white.jpg"}],"size":[{"val":32,"price":"1000"},{"val":24,"price":"1244"}]},{"type":"denim","colour":[{"name":"red","image":"red.jpg"},{"name":"white","image":"white.jpg"}],"size":[{"val":32,"price":1000},{"val":24,"price":1244}]}]},{"type":"superslim","model":[{"type":"denim","colour":[{"name":"red","image":"red.jpg"},{"name":"white","image":"white.jpg"}],"size":[{"val":32,"price":1000},{"val":24,"price":1244}]},{"type":"dobby","colour":[{"name":"red","image":"red.jpg"},{"name":"white","image":"white.jpg"}],"size":[{"val":32,"price":1000},{"val":24,"price":1244}]}]}]" (type string) at path "subcategory.0"" }

data.js

products: [
    {
      name: "Levis Jean",
      subcategory: [
        {
          type: "slimline",
          model: [
            {
              type: "twill",
              colour: [
                {
                  name: "red",
                  image: "red.jpg",
                },
                {
                  name: "white",
                  image: "white.jpg",
                },
              ],
              size: [
                {
                  val: 32,
                  price: "1000",
                },
                {
                  val: 24,
                  price: "1244",
                },
              ],
            },
            {
              type: "denim",
              colour: [
                {
                  name: "red",
                  image: "red.jpg",
                },
                {
                  name: "white",
                  image: "white.jpg",
                },
              ],
              size: [
                {
                  val: 32,
                  price: 1000,
                },
                {
                  val: 24,
                  price: 1244,
                },
              ],
            },
          ],
        },
        {
          type: "superslim",
          model: [
            {
              type: "denim",
              colour: [
                {
                  name: "red",
                  image: "red.jpg",
                },
                {
                  name: "white",
                  image: "white.jpg",
                },
              ],
              size: [
                {
                  val: 32,
                  price: 1000,
                },
                {
                  val: 24,
                  price: 1244,
                },
              ],
            },
            {
              type: "dobby",
              colour: [
                {
                  name: "red",
                  image: "red.jpg",
                },
                {
                  name: "white",
                  image: "white.jpg",
                },
              ],
              size: [
                {
                  val: 32,
                  price: 1000,
                },
                {
                  val: 24,
                  price: 1244,
                },
              ],
            },
          ],
        },
      ],
      category: "2AM",
      image: "/images/2AM/DSCF4739-5.jpg",
    },

productModel

import mongoose from "mongoose";
const productSchema = new mongoose.Schema(
  {
    name: { type: String, required: true, unique: true },
    category: { type: String, required: true },
    subcategory: [
      {
        type: String,
        model: [
          {
            type: String,
            colour: [
              {
                name: String,
                image: String,
              },
            ],
            size: [
              {
                val: Number,
                price: Number,
              },
            ],
          },
        ],
      },
    ],
    image: { type: String, required: true },
  },
  { timestamps: true },
  { versionKey: false },
  { strict: false }
);
const Product = mongoose.model("Product", productSchema);

export default Product;

I recommend against using type as a field name. I believe Mongoose is confused about which type is actually the type of the fields and which one is the name of the field. Try to change the field name into something else (e.g. subcategoryType or kind) and most likely the error will vanish.