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:
@@ -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,
|
||||
@@ -159,289 +167,288 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getMySkillByIdkill = function (idapp, idSkill) {
|
||||
MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) {
|
||||
const MySkill = this;
|
||||
|
||||
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};
|
||||
|
||||
Reference in New Issue
Block a user