My object is
[ { Indicator: 'RA', Year: '2019' },
{ Indicator: 'RR', Year: '2019' },
{ Indicator: 'ROOM REV', Year: '2019' },
{ Indicator: 'F&B REV', Year: '2019' },
{ Indicator: 'TOTAL REV', Year: '2019' },
{ Indicator: 'ROOM PROFIT', Year: '2019' },
{ Indicator: 'F&B PROFIT', Year: '2019' },
{ Indicator: 'GOP', Year: '2019' },
{ Indicator: 'BASIC', Year: '2019' },
{ Indicator: 'TRAD', Year: '2019' },
{ Indicator: 'INC', Year: '2019' } ]
and I want to add that object to single document.
Nodejs code;
router.post('/api/sendJsonTable', function(req,res,next){
var body = req.body
console.log(body)
Data.create(body, function (error, data) {
if (error) {
return next(error);
}
});
})
models
var DataSchema = new mongoose.Schema({
value: {
type: String,
trim: true
},
indicator: {
type: String,
trim: true
},
})
When try that code, the code create 11 documents.