Skip to content Skip to sidebar Skip to footer

Mongoose Schema Array Of Objects

I have big object like this: const example = { startMap: 'Something', monsters: [], monstersToOmit: [], mapsOrder: [1, 2], mapsData: [ { id:

Solution 1:

It would look likes this:

mapsData: [{
    id:Number,
    name:String,
    gates: [{
        toId:Number,
        coords: {
            x:Number,
            y:Number
        }
    }],
    waypoints: [[{x:Number, y:Number}]]
}]

you can always do mapsData:JSON when you're unsure and feel things out.

Post a Comment for "Mongoose Schema Array Of Objects"