From c24ddc4cf5b17d9991f925ee62c82ed3d2fae061 Mon Sep 17 00:00:00 2001 From: alfredojl Date: Tue, 6 Oct 2020 20:16:17 -0500 Subject: [PATCH] . --- helpers/tables/Ubicacion.js | 52 ++++++++++++++----------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/helpers/tables/Ubicacion.js b/helpers/tables/Ubicacion.js index 67c7853..6830c30 100644 --- a/helpers/tables/Ubicacion.js +++ b/helpers/tables/Ubicacion.js @@ -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; \ No newline at end of file +module.exports = Ubicacion; \ No newline at end of file