232 lines
5.5 KiB
JavaScript
232 lines
5.5 KiB
JavaScript
const activoFijo = require('../server/models/tablas/ActivoFijo');
|
|
const DescripcionAdicional = require('../server/models/tablas/DescripcionAdicional');
|
|
const Equipo = require('../server/models/tablas/Equipo');
|
|
const Inventario = require('../server/models/tablas/Inventario');
|
|
const Marca = require('../server/models/tablas/Marca');
|
|
const OS = require('../server/models/tablas/OS');
|
|
const Printers = require('../server/models/tablas/Printers');
|
|
const Tipo = require('../server/models/tablas/Tipo');
|
|
const Ubicacion = require('../server/models/tablas/Ubicacion');
|
|
const UResponsable = require('../server/models/tablas/UResponsable');
|
|
const Uso = require('../server/models/tablas/Uso');
|
|
|
|
const faker = require('faker');
|
|
faker.locale = "es_MX";
|
|
|
|
const colors = require('colors');
|
|
const symbols = require('log-symbols');
|
|
|
|
let rows = 5;
|
|
|
|
async function fillingUp() {
|
|
await fillActivoFijo();
|
|
await fillDA();
|
|
await fillEquipo();
|
|
await fillInventario();
|
|
await fillMarca();
|
|
await fillOS();
|
|
await fillPrinters();
|
|
await fillTipo();
|
|
await fillUbicacion();
|
|
await fillUResponsable();
|
|
await fillUso();
|
|
}
|
|
|
|
async function fillActivoFijo() {
|
|
let af = faker.random.arrayElement([
|
|
"PC",
|
|
"Laptop",
|
|
"Impresora",
|
|
"Servidor",
|
|
"Ipad",
|
|
"Chromebook"
|
|
]);
|
|
|
|
// console.log("Activo fijo: ", af);
|
|
|
|
await activoFijo.create({
|
|
activoFijo: af
|
|
});
|
|
|
|
}
|
|
|
|
async function fillDA() {
|
|
let da = faker.lorem.sentence();
|
|
|
|
// console.log("Descripción adicional: ", da);
|
|
|
|
await DescripcionAdicional.create({
|
|
descripcion: da
|
|
})
|
|
}
|
|
|
|
async function fillEquipo() {
|
|
let modelo = faker.vehicle.model();
|
|
let noSerie = faker.vehicle.vin();
|
|
let procesador = faker.random.arrayElement([
|
|
"Intel Core i3",
|
|
"Intel Core i5",
|
|
"Intel Core i7",
|
|
"Ryzen 3",
|
|
"Ryzen 5",
|
|
"Ryzen 7",
|
|
]);
|
|
let vProcesador = faker.random.number({ min: 2000, max: 4500 })
|
|
let memoria = faker.random.arrayElement([
|
|
"DDR2",
|
|
"DDR3",
|
|
"DDR4"
|
|
]);
|
|
let memoriasz = faker.random.arrayElement([
|
|
4096,
|
|
2048,
|
|
8192
|
|
]);
|
|
let vMemoria = faker.random.number({ min: 1400, max: 1800, precision: 4 });
|
|
let graficos = faker.random.arrayElement([
|
|
"Intel HD Graphics",
|
|
"Intel Iris",
|
|
"Intel Iris Plus",
|
|
"Radeon Vega 8",
|
|
"Radeon Vega 7",
|
|
"Radeon Vega Plus",
|
|
"Radeon Vega Graphics",
|
|
]);
|
|
let hdd = faker.random.number({
|
|
min: 80,
|
|
max: 990,
|
|
precision: 2
|
|
});
|
|
|
|
// console.log("Modelo: ", modelo, "\nNúmero de serie: ", noSerie, "\nProcesador: ", procesador, "\nVelocidad de procesador: ", vProcesador, "\nMemoria: ", memoria, "\nCantidad de memoria: ", memoriasz, "\nVelocidad de memoria: ", vMemoria, "\nGráficos: ", graficos, "\nTamaño de almacenamiento: ", hdd);
|
|
|
|
await Equipo.create({
|
|
modelo,
|
|
noSerie,
|
|
procesador,
|
|
vProcesador,
|
|
memoria,
|
|
memoriasz,
|
|
vMemoria,
|
|
graficos,
|
|
hdd
|
|
});
|
|
};
|
|
|
|
async function fillInventario() {
|
|
let noInventario = faker.phone.phoneNumber("2######")
|
|
let noResguardo = faker.phone.phoneNumber("#####")
|
|
// console.log("Inventario: ", noInventario, "\nResguardo: ", noResguardo);
|
|
|
|
await Inventario.create({
|
|
noInventario,
|
|
noResguardo
|
|
});
|
|
};
|
|
|
|
async function fillMarca() {
|
|
let marca = faker.random.arrayElement([
|
|
"HP",
|
|
"ECOIN",
|
|
"SONY",
|
|
"LENOVO",
|
|
"DELL",
|
|
"ACER",
|
|
"ASUS",
|
|
"APPLE",
|
|
"COMPAQ",
|
|
"GATEWAY",
|
|
"ECOIN",
|
|
"IBM"
|
|
]);
|
|
|
|
// console.log("Marca: ", marca);
|
|
|
|
await Marca.create({
|
|
marca
|
|
});
|
|
};
|
|
|
|
async function fillOS() {
|
|
let osname = faker.random.arrayElement([
|
|
"Windows 7",
|
|
"Windows 10",
|
|
"Debian",
|
|
"Fedora",
|
|
"CentOS",
|
|
"Ubuntu",
|
|
"MacOS"
|
|
]);
|
|
// console.log("Sistema operativo: ", osname);
|
|
|
|
await OS.create({
|
|
osname
|
|
});
|
|
};
|
|
|
|
async function fillPrinters() {
|
|
let noSerie = faker.vehicle.vin();
|
|
// console.log("Número de serie impresora: ", noSerie);
|
|
|
|
await Printers.create({
|
|
noSerie
|
|
});
|
|
};
|
|
|
|
async function fillTipo() {
|
|
let tipo = faker.random.arrayElement([
|
|
"Impresora",
|
|
"Multifuncional",
|
|
"Láser",
|
|
"Plotter"
|
|
]);
|
|
// console.log("Tipo de impresora: ", tipo);
|
|
|
|
await Tipo.create({
|
|
tipo
|
|
});
|
|
};
|
|
|
|
async function fillUbicacion() {
|
|
let ubicacion = faker.name.jobArea();
|
|
|
|
// console.log("Ubicación: ", ubicacion);
|
|
|
|
await Ubicacion.create({
|
|
ubicacion
|
|
});
|
|
};
|
|
|
|
async function fillUResponsable() {
|
|
let unidades = require('./unidades.json');
|
|
let uResponsable = faker.random.arrayElement(unidades);
|
|
let nombreResponsable = faker.name.findName();
|
|
// console.log("Unidad responsable: ", uResponsable, "\nNombre del responsable: ", nombreResponsable);
|
|
|
|
await UResponsable.create({
|
|
uResponsable,
|
|
nombreResponsable
|
|
});
|
|
};
|
|
|
|
async function fillUso() {
|
|
let uso = faker.name.jobType();
|
|
// console.log("Uso: ", uso);
|
|
|
|
await Uso.create({
|
|
uso
|
|
});
|
|
};
|
|
|
|
async function exec() {
|
|
|
|
console.log(symbols.info, "Filling up database...".blue.bold);
|
|
|
|
for (let i = 0; i < rows; i++) {
|
|
console.log(`Creating record ${i + 1}/${rows}.`.yellow);
|
|
await fillingUp();
|
|
}
|
|
console.log(symbols.success, `${ rows } records created succesfully.`.green.bold);
|
|
}
|
|
|
|
exec(); |