No es necesario crear una instancia new hostModel()
aquí... use directamente hostModel
y tampoco es necesario save()
también porque insertar muchos crea las colecciones ... y asegúrese de que payload.data
tiene una matriz de objetos
router.post('/host', function (req, res, next) {
const array = [{hostname: 'hostname', timestamp: 'timestamp'},
{hostname: 'hostname', timestamp: 'timestamp'}]
var payload = req.body;
(async function(){
const insertMany = await hostModel.insertMany(array);
console.log(JSON.stringify(insertMany,'','\t'));
res.status(200).send('Ok');
})();
});