Files
alfredojl ad82fab926 .
2020-10-09 21:52:33 -05:00

36 lines
1.0 KiB
JavaScript

const Ubicacion = require('../../server/models/tablas/Ubicacion');
const progress = require('cli-progress');
const colors = require('colors');
const faker = require('faker');
faker.locale = "es_MX";
async function fillUbicacion() {
let ubicaciones = require('./ubicaciones');
let limit = ubicaciones.length;
const bar = new progress.SingleBar({
format: 'ubicacion |' + colors.cyan('{bar}') + '| {percentage}%' + ' || {value}/{total} records created.',
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
hideCursor: true,
stopOnComplete: true,
barsize: 30,
align: 'right'
});
console.log('\n\tFilling out «ubicacion».'.cyan.italic.bold);
bar.start(limit, 0);
for (ubicacion of ubicaciones) {
await Ubicacion.create({
ubicacion
})
.catch(() => {
bar.stop();
throw new Error();
});
bar.increment();
};
};
module.exports = fillUbicacion;