0

To be able to use mongoose , we create models with the help of a Schema as:

const instanceSchema = new Schema(
    {
        
        _mid: {
            type: String,
            required: true,
        },
        created_by: {
            type: String,
            required: true,
        },
        stages: [
            id: {
                type: String,
                required: true,
            }
        ],
    },
    { timestamps: true }
);  

which we can use to store data such as:

{    
 _mid: "ONE",
created_by: "owner",
stages: [1,2,3,4]
}  

but, what would be the Schema for such a data:

{    
     _mid: "ONE",
    created_by: "owner",
    stages: { 
      1: {
           "name": "one"
         },
      2: {    
         "name": "two"
      }  
      . 
      .    // more data   
      .
      1000: {
         "name": "oneThousand"
      }
    }
   }  
juztcode
  • 1,196
  • 2
  • 21
  • 46

1 Answers1

0

I do not believe you would be able to get that structure as it isn't valid. You could try following this answer here and see if it helps :).

Xanik
  • 365
  • 3
  • 9