Aggiungere "San Marino" e suoi comuni
Corretto Filtro a mano della ricerca Creare filtro ricerca per trovare la sottocategoria o categoria -> Skill e SubSkill
This commit is contained in:
67
src/server/models/adtype.js
Executable file
67
src/server/models/adtype.js
Executable file
@@ -0,0 +1,67 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "";
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true;
|
||||
});
|
||||
|
||||
const AdTypeSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
AdTypeSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await AdType.findOne().limit(1).sort({_id:-1});
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
else
|
||||
this._id = myrec._doc._id + 1;
|
||||
} else {
|
||||
this._id = 1;
|
||||
}
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
AdTypeSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const AdType = this;
|
||||
|
||||
const query = [
|
||||
{$sort: {_id: 1}},
|
||||
];
|
||||
|
||||
return AdType.aggregate(query).then((arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
AdTypeSchema.statics.getFieldsForSearch = function() {
|
||||
return [
|
||||
{field: 'descr', type: tools.FieldType.string}];
|
||||
};
|
||||
|
||||
AdTypeSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, 0, params);
|
||||
};
|
||||
|
||||
const AdType = mongoose.model('AdType', AdTypeSchema);
|
||||
|
||||
module.exports = {AdType};
|
||||
@@ -47,7 +47,7 @@ const CitySchema = new Schema({
|
||||
},
|
||||
country: {
|
||||
type: String,
|
||||
maxlength: 2,
|
||||
maxlength: 3,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@ const MySkillSchema = new Schema({
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
@@ -66,9 +69,6 @@ const MySkillSchema = new Schema({
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
subTitle: {
|
||||
type: String,
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
@@ -116,15 +116,21 @@ MySkillSchema.statics.findAllIdApp = async function(idapp) {
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getFieldsForSearch = function() {
|
||||
return [];
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getFieldsLastForSearch = function() {
|
||||
return [
|
||||
{field: 'idSkill', type: tools.FieldType.Number}
|
||||
, {field: 'note', type: tools.FieldType.String}
|
||||
, {field: 'subTitle', type: tools.FieldType.String},
|
||||
{field: 'note', type: tools.FieldType.string},
|
||||
{field: 'descr', type: tools.FieldType.string},
|
||||
{field: 'recSkill.descr', type: tools.FieldType.string},
|
||||
{field: 'myskill.descr', type: tools.FieldType.string},
|
||||
];
|
||||
};
|
||||
|
||||
MySkillSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
params.fieldsearch_last = this.getFieldsLastForSearch();
|
||||
|
||||
const otherparams = {
|
||||
lookup1: {
|
||||
@@ -135,13 +141,15 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
af_objId_tab: 'myId',
|
||||
lk_proj: {
|
||||
idSkill: 1,
|
||||
idSubSkill: 1,
|
||||
myskill: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
numLevel: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
subTitle: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
@@ -164,284 +172,283 @@ MySkillSchema.statics.getMySkillByIdkill = function (idapp, idSkill) {
|
||||
|
||||
const query = [
|
||||
{
|
||||
"$match": {
|
||||
"$and": [
|
||||
'$match': {
|
||||
'$and': [
|
||||
{
|
||||
"_id": parseInt(idSkill)
|
||||
}
|
||||
]
|
||||
}
|
||||
'_id': parseInt(idSkill),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"$match": {
|
||||
"idapp": idapp
|
||||
}
|
||||
'$match': {
|
||||
'idapp': idapp,
|
||||
},
|
||||
},
|
||||
{
|
||||
"$sort": {
|
||||
"desc": 1
|
||||
}
|
||||
'$sort': {
|
||||
'desc': 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"myId1": {
|
||||
"$toObjectId": "$userId"
|
||||
}
|
||||
}
|
||||
'$addFields': {
|
||||
'myId1': {
|
||||
'$toObjectId': '$userId',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "users",
|
||||
"localField": "myId1",
|
||||
"foreignField": "_id",
|
||||
"as": "user"
|
||||
}
|
||||
'$lookup': {
|
||||
'from': 'users',
|
||||
'localField': 'myId1',
|
||||
'foreignField': '_id',
|
||||
'as': 'user',
|
||||
},
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
'$replaceRoot': {
|
||||
'newRoot': {
|
||||
'$mergeObjects': [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$user",
|
||||
0
|
||||
]
|
||||
'$arrayElemAt': [
|
||||
'$user',
|
||||
0,
|
||||
],
|
||||
},
|
||||
'$$ROOT',
|
||||
],
|
||||
},
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recSkill": 1,
|
||||
"sector": 1,
|
||||
"idSector": 1,
|
||||
"idSkill": 1,
|
||||
"idSubSkill": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"numLevel": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"subTitle": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
'numLevel': 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
'profile.qualifica': 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "skills",
|
||||
"localField": "idSkill",
|
||||
"foreignField": "_id",
|
||||
"as": "recSkill"
|
||||
}
|
||||
'$lookup': {
|
||||
'from': 'skills',
|
||||
'localField': 'idSkill',
|
||||
'foreignField': '_id',
|
||||
'as': 'recSkill',
|
||||
},
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
'$replaceRoot': {
|
||||
'newRoot': {
|
||||
'$mergeObjects': [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$recSkill",
|
||||
0
|
||||
]
|
||||
'$arrayElemAt': [
|
||||
'$recSkill',
|
||||
0,
|
||||
],
|
||||
},
|
||||
'$$ROOT',
|
||||
],
|
||||
},
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recSkill": 1,
|
||||
"sector": 1,
|
||||
"idSector": 1,
|
||||
"idSkill": 1,
|
||||
"idSubSkill": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"numLevel": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"subTitle": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
'numLevel': 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
'profile.qualifica': 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "sectors",
|
||||
"localField": "recSkill.idSector",
|
||||
"foreignField": "_id",
|
||||
"as": "sector"
|
||||
}
|
||||
'$lookup': {
|
||||
'from': 'sectors',
|
||||
'localField': 'recSkill.idSector',
|
||||
'foreignField': '_id',
|
||||
'as': 'sector',
|
||||
},
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
'$replaceRoot': {
|
||||
'newRoot': {
|
||||
'$mergeObjects': [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$sector",
|
||||
0
|
||||
]
|
||||
'$arrayElemAt': [
|
||||
'$sector',
|
||||
0,
|
||||
],
|
||||
},
|
||||
'$$ROOT',
|
||||
],
|
||||
},
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recSkill": 1,
|
||||
"sector": 1,
|
||||
"idSector": 1,
|
||||
"idSkill": 1,
|
||||
"idSubSkill": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"numLevel": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"subTitle": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
'numLevel': 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
'profile.qualifica': 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "subskills",
|
||||
"localField": "idSubSkill",
|
||||
"foreignField": "_id",
|
||||
"as": "myskill"
|
||||
}
|
||||
'$lookup': {
|
||||
'from': 'subskills',
|
||||
'localField': 'idSubSkill',
|
||||
'foreignField': '_id',
|
||||
'as': 'myskill',
|
||||
},
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
'$replaceRoot': {
|
||||
'newRoot': {
|
||||
'$mergeObjects': [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$myskill",
|
||||
0
|
||||
]
|
||||
'$arrayElemAt': [
|
||||
'$myskill',
|
||||
0,
|
||||
],
|
||||
},
|
||||
'$$ROOT',
|
||||
],
|
||||
},
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recSkill": 1,
|
||||
"sector": 1,
|
||||
"idSector": 1,
|
||||
"idSkill": 1,
|
||||
"idSubSkill": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"numLevel": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"subTitle": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
'numLevel': 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
'profile.qualifica': 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "cities",
|
||||
"localField": "idCity",
|
||||
"foreignField": "_id",
|
||||
"as": "mycities"
|
||||
}
|
||||
'$lookup': {
|
||||
'from': 'cities',
|
||||
'localField': 'idCity',
|
||||
'foreignField': '_id',
|
||||
'as': 'mycities',
|
||||
},
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
'$replaceRoot': {
|
||||
'newRoot': {
|
||||
'$mergeObjects': [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$mycities",
|
||||
0
|
||||
]
|
||||
'$arrayElemAt': [
|
||||
'$mycities',
|
||||
0,
|
||||
],
|
||||
},
|
||||
'$$ROOT',
|
||||
],
|
||||
},
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recSkill": 1,
|
||||
"sector": 1,
|
||||
"idSector": 1,
|
||||
"idSkill": 1,
|
||||
"idSubSkill": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"numLevel": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"subTitle": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
'numLevel': 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
'profile.qualifica': 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return MySkill.aggregate(query).then((rec) => {
|
||||
return rec ? rec[0] : null;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const MySkill = mongoose.model('MySkill', MySkillSchema);
|
||||
|
||||
module.exports = {MySkill};
|
||||
|
||||
6
src/server/populate/adtypes.js
Normal file
6
src/server/populate/adtypes.js
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
list: [
|
||||
{_id: 1, descr: 'Offro'},
|
||||
{_id: 2, descr: 'Cerco'},
|
||||
],
|
||||
};
|
||||
@@ -89012,5 +89012,269 @@ module.exports = {
|
||||
abitanti: 'M204',
|
||||
country: 'IT',
|
||||
},
|
||||
{
|
||||
_id: 8094,
|
||||
istat: '',
|
||||
comune: 'Acquaviva',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47892',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8095,
|
||||
istat: '',
|
||||
comune: 'Borgo Maggiore',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47893',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8096,
|
||||
istat: '',
|
||||
comune: 'Ca\' Rigo',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47893',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8097,
|
||||
istat: '',
|
||||
comune: 'Cailungo',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47893',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8098,
|
||||
istat: '',
|
||||
comune: 'Casole',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47890',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8099,
|
||||
istat: '',
|
||||
comune: 'Cerbaiola',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47898',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8100,
|
||||
istat: '',
|
||||
comune: 'Chiesanuova',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47894',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8101,
|
||||
istat: '',
|
||||
comune: 'Città di San Marino',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47890',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8102,
|
||||
istat: '',
|
||||
comune: 'Dogana',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47891',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8103,
|
||||
istat: '',
|
||||
comune: 'Domagnano',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47895',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8104,
|
||||
istat: '',
|
||||
comune: 'Faetano',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47896',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8105,
|
||||
istat: '',
|
||||
comune: 'Falciano',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47897',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8106,
|
||||
istat: '',
|
||||
comune: 'Galazzano',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47891',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8107,
|
||||
istat: '',
|
||||
comune: 'Gualdicciolo',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47892',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8108,
|
||||
istat: '',
|
||||
comune: 'Montegiardino',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47898',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8109,
|
||||
istat: '',
|
||||
comune: 'Murata',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47890',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8110,
|
||||
istat: '',
|
||||
comune: 'Rovereta',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47891',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8111,
|
||||
istat: '',
|
||||
comune: 'San Giovanni',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47893',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8112,
|
||||
istat: '',
|
||||
comune: 'Santa Mustiola',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47890',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8113,
|
||||
istat: '',
|
||||
comune: 'Serravalle',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47899',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8114,
|
||||
istat: '',
|
||||
comune: 'Teglio',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47894',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8115,
|
||||
istat: '',
|
||||
comune: 'Torraccia',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47895',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8116,
|
||||
istat: '',
|
||||
comune: 'Valdragone',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47893',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
{
|
||||
_id: 8117,
|
||||
istat: '',
|
||||
comune: 'Ventoso',
|
||||
prov: 'RSM',
|
||||
reg: 'RSM',
|
||||
pref: '0549',
|
||||
cap: '47893',
|
||||
abitanti: '',
|
||||
country: 'RSM',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -5,80 +5,66 @@ module.exports = {
|
||||
{
|
||||
"_id" : ObjectID("615a353c002c8298f4495be7"),
|
||||
"idapp" : "1",
|
||||
"__v" : 0,
|
||||
"label" : "Dono"
|
||||
},
|
||||
|
||||
{
|
||||
"_id" : ObjectID("61bc466567de9a1f54b25494"),
|
||||
"idapp" : "1",
|
||||
"__v" : 0,
|
||||
"label" : "Offerta Libera"
|
||||
},
|
||||
|
||||
{
|
||||
"_id" : ObjectID("61bc454867de9a1f54b25462"),
|
||||
"idapp" : "1",
|
||||
"__v" : 0,
|
||||
"label" : "Baratto"
|
||||
},
|
||||
|
||||
{
|
||||
"_id" : ObjectID("61bc482667de9a1f54b2549b"),
|
||||
"idapp" : "1",
|
||||
"__v" : 0,
|
||||
"label" : "Euro"
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("61bc482667de9a1f54b2549b"),
|
||||
"idapp" : "1",
|
||||
"__v" : 0,
|
||||
"label" : "Scambio di Beni"
|
||||
"label" : "Baratto (scambio Beni o Servizi)"
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("61bc482667de9a1f54b2549c"),
|
||||
"idapp" : "1",
|
||||
"__v" : 0,
|
||||
"label" : "Scambio di Lavoro"
|
||||
"label" : "Scambio Lavoro"
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("61bc482667de9a1f54b2649c"),
|
||||
"idapp" : "1",
|
||||
"label" : "Monete Alternative"
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("61bc482667de9a1f54b3549e"),
|
||||
"idapp" : "1",
|
||||
"label" : "Euro"
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("615a353c002c8298f4495bf7"),
|
||||
"idapp" : "12",
|
||||
"__v" : 0,
|
||||
"label" : "Dono"
|
||||
},
|
||||
|
||||
{
|
||||
"_id" : ObjectID("61bc466567de9a1f54b254f4"),
|
||||
"idapp" : "12",
|
||||
"__v" : 0,
|
||||
"label" : "Offerta Libera"
|
||||
},
|
||||
|
||||
{
|
||||
"_id" : ObjectID("61bc454867de9a1f54b254f2"),
|
||||
"idapp" : "12",
|
||||
"__v" : 0,
|
||||
"label" : "Baratto"
|
||||
},
|
||||
|
||||
{
|
||||
"_id" : ObjectID("61bc482667de9a1f54b254fb"),
|
||||
"idapp" : "12",
|
||||
"__v" : 0,
|
||||
"label" : "Euro"
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("61bc482667de9a1f54b25411"),
|
||||
"idapp" : "12",
|
||||
"__v" : 0,
|
||||
"label" : "Scambio di Beni"
|
||||
"label" : "Baratto (scambio Beni o Servizi)"
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("61bc482667de9a1f54b25412"),
|
||||
"idapp" : "12",
|
||||
"__v" : 0,
|
||||
"label" : "Scambio di Lavoro"
|
||||
"label" : "Scambio Lavoro"
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("61bc482667de9a1f64b254ab"),
|
||||
"idapp" : "12",
|
||||
"label" : "Monete Alternative"
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("61bc482667de9a1f64b254fb"),
|
||||
"idapp" : "12",
|
||||
"label" : "Euro"
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -24,11 +24,17 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
async insertIntoDb_NoDuplicate(tablename, table, field) {
|
||||
async insertIntoDb_NoDuplicate(attiva, tablename, table, field) {
|
||||
|
||||
let numrec = 0;
|
||||
try {
|
||||
|
||||
if (!attiva && await table.countDocuments({}) > 0)
|
||||
return;
|
||||
|
||||
const pathfile = Path.join(__dirname, tablename + '.js');
|
||||
if (tools.isFileExists(pathfile)) {
|
||||
|
||||
const mydbfile = require(pathfile);
|
||||
|
||||
if (mydbfile && mydbfile.list) {
|
||||
@@ -38,10 +44,17 @@ module.exports = {
|
||||
|
||||
var mynewrec = new table(rec);
|
||||
|
||||
if (rec.hasOwnProperty('idapp')) {
|
||||
obj.idapop = rec['idapp'];
|
||||
}
|
||||
|
||||
const exist = await table.find(obj);
|
||||
if (exist.length <= 0) {
|
||||
try {
|
||||
await mynewrec.save();
|
||||
const ris = await mynewrec.save();
|
||||
if (ris) {
|
||||
numrec++;
|
||||
}
|
||||
}catch (e){
|
||||
console.log('error ', e);
|
||||
}
|
||||
@@ -50,12 +63,63 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
if (numrec > 0)
|
||||
console.log('*** Insert', numrec, 'record on '+tablename);
|
||||
|
||||
}
|
||||
}
|
||||
}catch (e){
|
||||
console.log('error insertIntoDb', e);
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
async rewriteTable(table) {
|
||||
|
||||
let mytab = null;
|
||||
let field = '';
|
||||
|
||||
const {City} = require('../models/city');
|
||||
const {Province} = require('../models/province');
|
||||
const {Sector} = require('../models/sector');
|
||||
const {Skill} = require('../models/skill');
|
||||
const {SubSkill} = require('../models/subskill');
|
||||
const {Contribtype} = require('../models/contribtype');
|
||||
const {Level} = require('../models/level');
|
||||
|
||||
if (table === 'cities') {
|
||||
mytab = City;
|
||||
field = 'comune';
|
||||
} else if (table === 'provinces') {
|
||||
mytab = Province;
|
||||
field = 'descr';
|
||||
} else if (table === 'sectors') {
|
||||
mytab = Sector;
|
||||
field = 'descr';
|
||||
} else if (table === 'skills') {
|
||||
mytab = Skill;
|
||||
field = 'descr';
|
||||
} else if (table === 'subskills') {
|
||||
mytab = SubSkill;
|
||||
field = 'descr';
|
||||
} else if (table === 'contribtypes') {
|
||||
mytab = Contribtype;
|
||||
field = 'label';
|
||||
} else if (table === 'levels') {
|
||||
mytab = Level;
|
||||
field = 'descr';
|
||||
}
|
||||
|
||||
if (mytab) {
|
||||
console.log('Delete ', table)
|
||||
await mytab.deleteMany({});
|
||||
|
||||
await this.insertIntoDb_NoDuplicate(false, table, mytab, field)
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
async popolaTabelleNuove() {
|
||||
@@ -65,45 +129,51 @@ module.exports = {
|
||||
let ris = null;
|
||||
try {
|
||||
|
||||
if (abilita) {
|
||||
const {City} = require('../models/city');
|
||||
const {Province} = require('../models/province');
|
||||
|
||||
console.log('INIZIO - popolaTabelleNuove')
|
||||
|
||||
// Sectors
|
||||
const {Sector} = require('../models/sector');
|
||||
await this.insertIntoDb_NoDuplicate('sectors', Sector, 'descr')
|
||||
await this.insertIntoDb_NoDuplicate(abilita, 'sectors', Sector, 'descr')
|
||||
|
||||
// CatGrps
|
||||
const {CatGrp} = require('../models/catgrp');
|
||||
await this.insertIntoDb_NoDuplicate('catgrps', CatGrp, 'descr')
|
||||
await this.insertIntoDb_NoDuplicate(abilita, 'catgrps', CatGrp, 'descr')
|
||||
|
||||
// Skills (Competenze)
|
||||
const {Skill} = require('../models/skill');
|
||||
await this.insertIntoDb_NoDuplicate('skills', Skill, 'descr')
|
||||
await this.insertIntoDb_NoDuplicate(abilita, 'skills', Skill, 'descr')
|
||||
|
||||
// SubSectors
|
||||
const {SubSkill} = require('../models/subskill');
|
||||
await this.insertIntoDb_NoDuplicate('subskills', SubSkill, 'descr')
|
||||
await this.insertIntoDb_NoDuplicate(abilita, 'subskills', SubSkill, 'descr')
|
||||
|
||||
// Levels
|
||||
const {Level} = require('../models/level');
|
||||
await this.insertIntoDb_NoDuplicate('levels', Level, 'descr')
|
||||
await this.insertIntoDb_NoDuplicate(abilita, 'levels', Level, 'descr')
|
||||
|
||||
// Status
|
||||
const {StatusSkill} = require('../models/statusSkill');
|
||||
await this.insertIntoDb_NoDuplicate('statusskills', StatusSkill, 'descr')
|
||||
await this.insertIntoDb_NoDuplicate(abilita, 'statusskills', StatusSkill, 'descr')
|
||||
|
||||
if (scrivi_citta) {
|
||||
// Cities
|
||||
const {City} = require('../models/city');
|
||||
await this.insertIntoDb('cities', City)
|
||||
await this.insertIntoDb_NoDuplicate(scrivi_citta, 'cities', City, 'comune')
|
||||
|
||||
// Province
|
||||
const {Province} = require('../models/province');
|
||||
await this.insertIntoDb('provinces', Province)
|
||||
}
|
||||
await this.insertIntoDb_NoDuplicate(scrivi_citta, 'provinces', Province, 'descr')
|
||||
console.log('FINE - Scrivo le Città')
|
||||
|
||||
// Contribtypes
|
||||
const {Contribtype} = require('../models/contribtype');
|
||||
await this.insertIntoDb_NoDuplicate('contribtypes', Contribtype, 'label')
|
||||
}
|
||||
await this.insertIntoDb_NoDuplicate(abilita, 'contribtypes', Contribtype, 'label')
|
||||
|
||||
const {AdType} = require('../models/adtype');
|
||||
await this.insertIntoDb_NoDuplicate(abilita, 'adtypes', AdType, 'descr')
|
||||
|
||||
console.log('FINE - popolaTabelleNuove')
|
||||
|
||||
}catch (e) {
|
||||
console.error('Err: ' + e);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ const {Province} = require('../models/province');
|
||||
const {Sector} = require('../models/sector');
|
||||
const {CatGrp} = require('../models/catgrp');
|
||||
const {Level} = require('../models/level');
|
||||
const {AdType} = require('../models/adtype');
|
||||
const Pickup = require('../models/pickup');
|
||||
const {Newstosent} = require('../models/newstosent');
|
||||
const {MyPage} = require('../models/mypage');
|
||||
@@ -1099,6 +1100,7 @@ function load(req, res, version) {
|
||||
|
||||
// SKILLS:
|
||||
let levels = Level.findAllIdApp(idapp);
|
||||
let adtypes = AdType.findAllIdApp(idapp);
|
||||
let skills = Skill.findAllIdApp(idapp);
|
||||
let subSkills = SubSkill.findAllIdApp(idapp);
|
||||
let statusSkills = StatusSkill.findAllIdApp(idapp);
|
||||
@@ -1162,6 +1164,7 @@ function load(req, res, version) {
|
||||
cities,
|
||||
myuserextra,
|
||||
catgrps,
|
||||
adtypes,
|
||||
]).then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
let myuser = req.user;
|
||||
@@ -1235,6 +1238,7 @@ function load(req, res, version) {
|
||||
cities: arrdata[29],
|
||||
// myuser arrdata[30]
|
||||
catgrps: arrdata[31],
|
||||
adtypes: arrdata[32],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -562,6 +562,8 @@ async function eseguiDbOp(idapp, mydata, locale) {
|
||||
|
||||
let ris = await User.DbOp(idapp, mydata);
|
||||
|
||||
const populate = require('../populate/populate');
|
||||
|
||||
let mystr = '';
|
||||
|
||||
try {
|
||||
@@ -866,15 +868,46 @@ async function eseguiDbOp(idapp, mydata, locale) {
|
||||
|
||||
await User.setVerifiedByAportadorToALL();
|
||||
|
||||
} else if (mydata.dbop === 'RewriteContribType') {
|
||||
|
||||
populate.rewriteTable('contribtypes');
|
||||
|
||||
} else if (mydata.dbop === 'emptyDbSkill') {
|
||||
|
||||
const {Sector} = require('../models/sector');
|
||||
const {Skill} = require('../models/skill');
|
||||
const {SubSkill} = require('../models/subskill');
|
||||
const {City} = require('../models/city');
|
||||
const {Province} = require('../models/province');
|
||||
|
||||
await Sector.remove({});
|
||||
await Skill.remove({});
|
||||
await SubSkill.remove({});
|
||||
await Sector.deleteMany({});
|
||||
await Skill.deleteMany({});
|
||||
await SubSkill.deleteMany({});
|
||||
await City.deleteMany({});
|
||||
await Province.deleteMany({});
|
||||
|
||||
} else if (mydata.dbop === 'PopulateTables') {
|
||||
|
||||
populate.popolaTabelleNuove();
|
||||
|
||||
} else if (mydata.dbop === 'RewriteCitiesTable') {
|
||||
|
||||
populate.rewriteTable('cities');
|
||||
} else if (mydata.dbop === 'RewriteLevelTable') {
|
||||
|
||||
populate.rewriteTable('levels');
|
||||
|
||||
} else if (mydata.dbop === 'RewriteLevelsTable') {
|
||||
|
||||
populate.rewriteTable('provinces');
|
||||
|
||||
} else if (mydata.dbop === 'emptyCityProvinces') {
|
||||
|
||||
const {City} = require('../models/city');
|
||||
const {Province} = require('../models/province');
|
||||
|
||||
await City.remove({});
|
||||
await Province.remove({});
|
||||
|
||||
/*} else if (mydata.dbop === 'visuNave') {
|
||||
mystr = await Nave.getNavePos(idapp, parseInt(mydata.riga), parseInt(mydata.col));
|
||||
|
||||
@@ -3,7 +3,7 @@ const tools = require('../tools/general');
|
||||
const appTelegram = [tools.FREEPLANET];
|
||||
|
||||
const appTelegram_TEST = [tools.FREEPLANET, tools.PDNM];
|
||||
const appTelegram_DEVELOP = [tools.FREEPLANET];
|
||||
const appTelegram_DEVELOP = [tools.PDNM];
|
||||
|
||||
const appTelegramFinti = ['2', tools.CNM];
|
||||
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET];
|
||||
|
||||
@@ -1199,6 +1199,36 @@ module.exports = {
|
||||
return query;
|
||||
},
|
||||
|
||||
getFilterParam: function(filter, fieldsearch) {
|
||||
let myregexp = {};
|
||||
myregexp = new RegExp(filter.trim().replace(' ', '|'), 'ig');
|
||||
|
||||
let query = [];
|
||||
|
||||
const myfilters = [];
|
||||
for (const rec of fieldsearch){
|
||||
let data = {};
|
||||
if (rec.type === this.FieldType.exact) {
|
||||
data[rec.field] = filter.trim();
|
||||
} else if (rec.type === this.FieldType.string) {
|
||||
data[rec.field] = myregexp;
|
||||
} else if ((rec.type === this.FieldType.number) ||
|
||||
(rec.type === this.FieldType.hours)) {
|
||||
data[rec.field] = parseFloat(filter.trim());
|
||||
}
|
||||
if (data)
|
||||
myfilters.push(data);
|
||||
}
|
||||
|
||||
if (myfilters.length > 0) {
|
||||
query = [
|
||||
{$match: {$or: myfilters}},
|
||||
];
|
||||
}
|
||||
|
||||
return query;
|
||||
},
|
||||
|
||||
getQueryTable: function(idapp, params) {
|
||||
|
||||
if (typeof params.startRow !== 'number') {
|
||||
@@ -1212,27 +1242,10 @@ module.exports = {
|
||||
let query = [];
|
||||
|
||||
if (params.filter && params.fieldsearch) {
|
||||
|
||||
let myregexp = {};
|
||||
myregexp = new RegExp(params.filter.trim().replace(' ', '|'), 'ig');
|
||||
|
||||
const myfilters = [];
|
||||
params.fieldsearch.forEach((rec) => {
|
||||
const data = {};
|
||||
if (rec.type === this.FieldType.exact) {
|
||||
data[rec.field] = params.filter.trim();
|
||||
} else if (rec.type === this.FieldType.string) {
|
||||
data[rec.field] = myregexp;
|
||||
} else if ((rec.type === this.FieldType.number) ||
|
||||
(rec.type === this.FieldType.hours)) {
|
||||
data[rec.field] = parseFloat(params.filter.trim());
|
||||
const querytemp = this.getFilterParam(params.filter, params.fieldsearch);
|
||||
if (querytemp){
|
||||
query = [...query, ...querytemp]
|
||||
}
|
||||
myfilters.push(data);
|
||||
});
|
||||
|
||||
query = [
|
||||
{$match: {$or: myfilters}},
|
||||
];
|
||||
}
|
||||
|
||||
let filtriadded = [];
|
||||
@@ -1505,6 +1518,13 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
if (params.filter && params.fieldsearch_last) {
|
||||
const querytemp = this.getFilterParam(params.filter, params.fieldsearch_last);
|
||||
if (querytemp){
|
||||
query = [...query, ...querytemp]
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// VECCHIA VERSIONE
|
||||
const q1 = this.getLookup(params, 1);
|
||||
@@ -2447,6 +2467,7 @@ module.exports = {
|
||||
|
||||
sulServer() {
|
||||
return process.env.LOCALE !== '1'
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user