.
This commit is contained in:
+20
-32
@@ -1,34 +1,22 @@
|
||||
const Ubicacion = require('../../server/models/tablas/Ubicacion');
|
||||
const progress = require('cli-progress');
|
||||
const colors = require('colors');
|
||||
const Sequelize = require("sequelize");
|
||||
const sequelize = require("../../config/sequelize.conf");
|
||||
|
||||
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'
|
||||
});
|
||||
class Ubicacion extends Sequelize.Model {}
|
||||
Ubicacion.init({
|
||||
idUbicacion: {
|
||||
type: Sequelize.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
allowNull: false,
|
||||
},
|
||||
ubicacion: {
|
||||
type: Sequelize.CHAR,
|
||||
allowNull: false,
|
||||
// unique: true
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
tableName: "ubicacion",
|
||||
});
|
||||
|
||||
console.log('\n\tFilling out «ubicacion».'.cyan.italic.bold);
|
||||
|
||||
bar.start(limit, 0);
|
||||
for (ubicacion of ubicaciones) {
|
||||
await Ubicacion.create({
|
||||
ubicacion
|
||||
})
|
||||
.catch((e) => {
|
||||
bar.stop();
|
||||
console.log(e);
|
||||
throw new Error(e);
|
||||
});
|
||||
bar.increment();
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = fillUbicacion;
|
||||
module.exports = Ubicacion;
|
||||
Reference in New Issue
Block a user