- add categories: skills and subskills.
This commit is contained in:
@@ -3,7 +3,7 @@ const Path = require('path')
|
||||
|
||||
module.exports = {
|
||||
|
||||
insertIntoDb(tablename, table) {
|
||||
async insertIntoDb(tablename, table) {
|
||||
|
||||
try {
|
||||
const pathfile = Path.join(__dirname, tablename + '.js');
|
||||
@@ -24,49 +24,88 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
popolaTabelleNuove() {
|
||||
const abilita = false;
|
||||
async insertIntoDb_NoDuplicate(tablename, table, field) {
|
||||
|
||||
try {
|
||||
const pathfile = Path.join(__dirname, tablename + '.js');
|
||||
if (tools.isFileExists(pathfile)) {
|
||||
const mydbfile = require(pathfile);
|
||||
|
||||
if (mydbfile && mydbfile.list) {
|
||||
for (const rec of mydbfile.list) {
|
||||
let obj = {}
|
||||
obj[field] = rec[field];
|
||||
|
||||
var mynewrec = new table(rec);
|
||||
|
||||
const exist = await table.find(obj);
|
||||
if (exist.length <= 0) {
|
||||
try {
|
||||
await mynewrec.save();
|
||||
}catch (e){
|
||||
console.log('error ', e);
|
||||
}
|
||||
|
||||
//await table.insertMany(rec, {ordered: false});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}catch (e){
|
||||
console.log('error insertIntoDb', e);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
async popolaTabelleNuove() {
|
||||
const abilita = true;
|
||||
const scrivi_citta = false;
|
||||
|
||||
let ris = null;
|
||||
if (abilita) {
|
||||
// Sectors
|
||||
const { Sector } = require('../models/sector');
|
||||
this.insertIntoDb('sectors', Sector)
|
||||
try {
|
||||
|
||||
// CatGrps
|
||||
const { CatGrp } = require('../models/catgrp');
|
||||
this.insertIntoDb('catgrps', CatGrp)
|
||||
if (abilita) {
|
||||
// Sectors
|
||||
const {Sector} = require('../models/sector');
|
||||
await this.insertIntoDb_NoDuplicate('sectors', Sector, 'descr')
|
||||
|
||||
// Skills (Competenze)
|
||||
const { Skill } = require('../models/skill');
|
||||
this.insertIntoDb('skills', Skill)
|
||||
// CatGrps
|
||||
const {CatGrp} = require('../models/catgrp');
|
||||
await this.insertIntoDb_NoDuplicate('catgrps', CatGrp, 'descr')
|
||||
|
||||
// SubSectors
|
||||
const { SubSkill } = require('../models/subskill');
|
||||
this.insertIntoDb('subskills', SubSkill)
|
||||
// Skills (Competenze)
|
||||
const {Skill} = require('../models/skill');
|
||||
await this.insertIntoDb_NoDuplicate('skills', Skill, 'descr')
|
||||
|
||||
// Levels
|
||||
const { Level } = require('../models/level');
|
||||
this.insertIntoDb('levels', Level)
|
||||
// SubSectors
|
||||
const {SubSkill} = require('../models/subskill');
|
||||
await this.insertIntoDb_NoDuplicate('subskills', SubSkill, 'descr')
|
||||
|
||||
// Status
|
||||
const { StatusSkill } = require('../models/statusSkill');
|
||||
this.insertIntoDb('statusskills', StatusSkill)
|
||||
// Levels
|
||||
const {Level} = require('../models/level');
|
||||
await this.insertIntoDb_NoDuplicate('levels', Level, 'descr')
|
||||
|
||||
if (scrivi_citta) {
|
||||
// Cities
|
||||
const {City} = require('../models/city');
|
||||
this.insertIntoDb('cities', City)
|
||||
// Status
|
||||
const {StatusSkill} = require('../models/statusSkill');
|
||||
await this.insertIntoDb_NoDuplicate('statusskills', StatusSkill, 'descr')
|
||||
|
||||
// Province
|
||||
const {Province} = require('../models/province');
|
||||
this.insertIntoDb('provinces', Province)
|
||||
if (scrivi_citta) {
|
||||
// Cities
|
||||
const {City} = require('../models/city');
|
||||
await this.insertIntoDb('cities', City)
|
||||
|
||||
// Province
|
||||
const {Province} = require('../models/province');
|
||||
await this.insertIntoDb('provinces', Province)
|
||||
}
|
||||
|
||||
// Contribtypes
|
||||
const {Contribtype} = require('../models/contribtype');
|
||||
await this.insertIntoDb_NoDuplicate('contribtypes', Contribtype, 'label')
|
||||
}
|
||||
|
||||
// Contribtypes
|
||||
const { Contribtype } = require('../models/contribtype');
|
||||
this.insertIntoDb('contribtypes', Contribtype)
|
||||
}catch (e) {
|
||||
console.error('Err: ' + e);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user