Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MongoDB/Mongoose插入具有数组对象的数组对象_Mongodb_Mongoose_Mongoose Schema - Fatal编程技术网

MongoDB/Mongoose插入具有数组对象的数组对象

MongoDB/Mongoose插入具有数组对象的数组对象,mongodb,mongoose,mongoose-schema,Mongodb,Mongoose,Mongoose Schema,我有以下mongo模式: const schema = mongoose.Schema({ months: [{ performance: [{ yield: Number, angle: Number, }] }], createdAt: { type: Date, default: new Date(), }, }); 我想用以下文档初始化此集合:

我有以下mongo模式:

const schema = mongoose.Schema({
    months: [{
        performance: [{
            yield: Number,
            angle: Number,
        }]
    }],
    createdAt: {
        type: Date,
        default: new Date(),
    },
});
我想用以下文档初始化此集合:

{
            "months": [
                {
                    "performance": [
                        {
                            "yield": 256,
                            "angle": 40
                        },
                        {
                            "yield": 256,
                            "angle": 40
                        }
                    ]
                },
                {
                    "peformance": [
                        {
                            "yield": 256,
                            "angle": 40
                        }
                    ]
                },
            ]
        },
我运行Collection.insertMany(元素)

在db中,我只看到months.performance,并且performance被指示为一个数组,但始终为空(收益率和角度从未被存储)。看起来mongo没有插入嵌套数组,或者我做错了什么

**另外,是否有一种推荐的替代方法来对这种模式进行建模**

任何帮助都将不胜感激

谢谢