42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
const Tipo = require('../../server/models/tablas/Tipo');
|
|
const progress = require('cli-progress');
|
|
const colors = require('colors');
|
|
|
|
async function fillTipo() {
|
|
let limit = 4;
|
|
const bar = new progress.SingleBar({
|
|
format: 'tipo |' + colors.cyan('{bar}') + '| {percentage}%' + ' || {value}/{total} records created.',
|
|
barCompleteChar: '\u2588',
|
|
barIncompleteChar: '\u2591',
|
|
hideCursor: true,
|
|
stopOnComplete: true,
|
|
barsize: 30,
|
|
align: 'right'
|
|
});
|
|
let tipos = [
|
|
"Impresora",
|
|
"Multifuncional",
|
|
"Láser",
|
|
"Plotter"
|
|
];
|
|
|
|
console.log('\n\tFilling out «tipo».'.cyan.italic.bold);
|
|
|
|
bar.start(limit, 0);
|
|
for (tipo of tipos) {
|
|
await Tipo.create({
|
|
tipo
|
|
})
|
|
// .then(() => {
|
|
// console.log(`${ count }/${ limit }\trecords created.`);
|
|
// count++;
|
|
// })
|
|
.catch(() => {
|
|
bar.stop();
|
|
throw new Error();
|
|
});
|
|
bar.increment();
|
|
};
|
|
};
|
|
|
|
module.exports = fillTipo; |