const Marca = require('../../server/models/tablas/Marca'); const progress = require('cli-progress'); const colors = require('colors'); async function fillMarca() { let limit = 11; const bar = new progress.SingleBar({ format: 'marca |' + colors.cyan('{bar}') + '| {percentage}%' + ' || {value}/{total} records created.', barCompleteChar: '\u2588', barIncompleteChar: '\u2591', hideCursor: true, stopOnComplete: true, barsize: 30, align: 'right' }); let marcas = [ "HP", "ECOIN", "SONY", "LENOVO", "DELL", "ACER", "ASUS", "APPLE", "COMPAQ", "GATEWAY", "IBM" ]; console.log('\n\tFilling out «marca».'.cyan.italic.bold); bar.start(limit, 0); for (marca of marcas) { await Marca.create({ marca }) .then(() => { // console.log(`${ count }/${ limit }\trecords created.`); }) .catch(() => { bar.stop(); throw new Error(); }); bar.increment(); }; }; module.exports = fillMarca;