将数据添加到我的猫鼬数组内的数组

时间:2019-04-14 10:27:35

标签: javascript mongoose-schema

猫鼬模式无法在数组中创建数组,我该怎么做?

plantationLocation和productExpense字段如何添加?

    seasonIdentification: [{
                   ....
            plantation: [{
                    .....
                    plantationLocation: [{
                            ....
                    }],
                    productSheama: [{
                            .....
                            productExpense: [{
                                    ....
                            }],

                    }]
            }]

exports.plantationLocation= function (req, res) {
    agriculture_User.update({_id:req.params.id,'season._id':req.params.seasonId,'plantation._id':req.params.plantationId}, {
        '$push':{
            'seasonIdentification.$.plantation.$.plantationLocation':[{
                'lat': 1231,
                'long': 12345,
                'Accuracy': 123456,
            }]
        }
    }, function (err, product) {
        if (err) res.send(err);
        res.send('Plantation Location true.');
    });
};

0 个答案:

没有答案