nuova veste grafica: myskills, mygoods, mybachecas, myhosps,

- cambiato id (da numero a stringa)
This commit is contained in:
Surya Paolo
2023-04-07 02:45:21 +02:00
parent 8a77dabc22
commit 94ef2c4c85
15 changed files with 1582 additions and 972 deletions

View File

@@ -195,7 +195,8 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount) {
AccountSchema.pre('save', async function (next) {
if (this.isNew) {
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();

View File

@@ -7,6 +7,7 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -82,7 +83,6 @@ const MyBachecaSchema = new Schema({
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
@@ -91,7 +91,8 @@ const MyBachecaSchema = new Schema({
MyBachecaSchema.pre('save', async function (next) {
if (this.isNew) {
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();
@@ -136,39 +137,7 @@ MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
idSkill: 1,
idSubSkill: 1,
MyBacheca: 1,
idStatusSkill: 1,
idContribType: 1,
dateTimeStart: 1,
dateTimeEnd: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
//**ADDFIELD_MYBACHECAS
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
'profile.username_telegram': 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
lk_proj: this.getProject(),
},
};
@@ -181,22 +150,13 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
const MyBacheca = this;
let myparsid = {
$or: [
{
'_id': parseInt(idGood)
},
{
'_id': idGood,
}]
'_id': id,
};
const query = [
let query = [
{
'$match': {
'$and': [
myparsid,
],
},
'$match':
myparsid,
},
{
'$match': {
@@ -239,40 +199,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
'$project': this.getProject(),
},
{
'$lookup': {
@@ -298,40 +225,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
'$project': this.getProject(),
},
{
'$lookup': {
@@ -357,40 +251,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
'$project': this.getProject(),
},
/*{
'$lookup': {
@@ -416,40 +277,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
'$project': this.getProject(),
},
{
'$lookup': {
@@ -474,49 +302,45 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYBACHECAS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
query = query.push(
{
$project: this.getProject(objadd.proj),
}
);
return MyBacheca.aggregate(query).then((rec) => {
return rec ? rec[0] : null;
});
};
MyBachecaSchema.statics.getProject = function (proj_add2) {
let proj = {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
// 'idSubSkill': 1,
idStatusSkill: 1,
idContribType: 1,
dateTimeStart: 1,
dateTimeEnd: 1,
website: 1,
//**ADDFIELD_MYBACHECAS
};
const proj_add = shared_consts.getProjectForAll(proj_add2)
return Object.assign({}, proj, proj_add);
}
MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
const MyBacheca = this;

View File

@@ -6,6 +6,8 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
@@ -80,7 +82,6 @@ const MyGoodSchema = new Schema({
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
@@ -89,18 +90,8 @@ const MyGoodSchema = new Schema({
MyGoodSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyGood.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;
}
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();
@@ -145,37 +136,7 @@ MyGoodSchema.statics.executeQueryTable = function (idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
idGood: 1,
idShipping: 1,
MyGood: 1,
idStatusGood: 1,
idContribType: 1,
'profile.username_telegram': 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
otherfilters: 1,
photos: 1,
note: 1,
website: 1,
//**ADDFIELD_MyGood
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
lk_proj: this.getProject(),
},
};
@@ -188,22 +149,13 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
const MyGood = this;
let myparsid = {
$or: [
{
'_id': parseInt(idGood)
},
{
'_id': idGood,
}]
'_id': idGood,
};
const query = [
let query = [
{
'$match': {
'$and': [
'$match':
myparsid,
],
},
},
{
'$match': {
@@ -246,39 +198,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
note: 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -304,39 +224,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -363,39 +251,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -421,39 +277,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -478,41 +302,17 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
},
},
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYGOODS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
query = [...query,
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
},
$project: this.getProject(objadd.proj),
}
];
return MyGood.aggregate(query).then((rec) => {
@@ -527,6 +327,23 @@ MyGoodSchema.statics.getCompleteRecord = function (idapp, id) {
};
MyGoodSchema.statics.getProject = function () {
let proj = {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
//**ADDFIELD_MYGOOD
};
const proj_add = shared_consts.getProjectForAll()
return Object.assign({}, proj, proj_add);
}
const MyGood = mongoose.model('MyGood', MyGoodSchema);

View File

@@ -15,7 +15,10 @@ mongoose.plugin(schema => {
const MyGroupSchema = new Schema({
_id: {
type: String,
type: String,
default: function () {
return new ObjectID().toString();
},
},
idapp: {
type: String,
@@ -144,18 +147,8 @@ MyGroupSchema.statics.executeQueryTable = function (idapp, params, user) {
MyGroupSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyGroup.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;
}
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();

View File

@@ -6,7 +6,8 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const {ObjectID} = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -21,7 +22,7 @@ const MyHospSchema = new Schema({
type: String,
required: true,
},
userId: {type: Schema.Types.ObjectId, ref: 'User'},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
visibile: {
type: Boolean
},
@@ -85,38 +86,27 @@ const MyHospSchema = new Schema({
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
},
});
MyHospSchema.pre('save', async function(next) {
MyHospSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyHosp.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;
}
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();
});
MyHospSchema.statics.findAllIdApp = async function(idapp) {
MyHospSchema.statics.findAllIdApp = async function (idapp) {
const MyHosp = this;
const query = [
{$match: {idapp}},
{$sort: {descr: 1}},
{ $match: { idapp } },
{ $sort: { descr: 1 } },
];
return await MyHosp.aggregate(query).then((arrrec) => {
@@ -125,18 +115,18 @@ MyHospSchema.statics.findAllIdApp = async function(idapp) {
};
MyHospSchema.statics.getFieldsForSearch = function() {
MyHospSchema.statics.getFieldsForSearch = function () {
return [];
};
MyHospSchema.statics.getFieldsLastForSearch = function() {
MyHospSchema.statics.getFieldsLastForSearch = function () {
return [
{field: 'descr', type: tools.FieldType.string},
{field: 'note', type: tools.FieldType.string},
{ field: 'descr', type: tools.FieldType.string },
{ field: 'note', type: tools.FieldType.string },
];
};
MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
MyHospSchema.statics.executeQueryTable = function (idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -147,69 +137,24 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
'mycities': 1,
reported: 1,
},
lk_proj: this.getProject(),
},
};
params = {...params, ...otherparams};
params = { ...params, ...otherparams };
return tools.executeQueryTable(this, idapp, params, user);
};
MyHospSchema.statics.getMyRecById = function(idapp, id) {
MyHospSchema.statics.getMyRecById = function (idapp, id) {
const MyHosp = this;
let myparsid = {
$or: [
{
'_id': parseInt(idGood)
},
{
'_id': idGood,
}]
};
const myparsid = { '_id': id };
if (tools.isNumber(id)) {
myparsid = {'_id': parseInt(id)};
} else {
myparsid = {'_id': id};
}
const query = [
let query = [
{
'$match': {
'$and': [
'$match':
myparsid,
],
},
},
{
'$match': {
@@ -252,35 +197,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 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.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -306,35 +223,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 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.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -360,35 +249,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 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.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
/*{
'$lookup': {
@@ -414,35 +275,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 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.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -467,38 +300,17 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYHOSPS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
query = [...query,
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
'profile.username_telegram': 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 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.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
},
$project: this.getProject(objadd.proj),
}
];
return MyHosp.aggregate(query).then((rec) => {
@@ -506,13 +318,34 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
});
};
MyHospSchema.statics.getCompleteRecord = function(idapp, id) {
MyHospSchema.statics.getCompleteRecord = function (idapp, id) {
const MyHosp = this;
return MyHosp.getMyRecById(idapp, id);
};
MyHospSchema.statics.getProject = function () {
let proj = {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
website: 1,
link_maplocation: 1,
//**ADDFIELD_MYHOSP
};
const proj_add = shared_consts.getProjectForAll()
return Object.assign({}, proj, proj_add);
}
const MyHosp = mongoose.model('MyHosp', MyHospSchema);
module.exports = {MyHosp};
module.exports = { MyHosp };

View File

@@ -6,6 +6,8 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
const {ObjectID} = require('mongodb');
// Resolving error Unknown modifier: $pushAll
@@ -86,7 +88,6 @@ const MySkillSchema = new Schema({
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
@@ -95,7 +96,8 @@ const MySkillSchema = new Schema({
MySkillSchema.pre('save', async function(next) {
if (this.isNew) {
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();
@@ -139,36 +141,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
idSkill: 1,
// idSubSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
'profile.username_telegram': 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
//**ADDFIELD_MYSKILL
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
lk_proj: this.getProject(),
},
};
@@ -180,20 +153,10 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
const MySkill = this;
let myparskill = {};
if (tools.isNumber(idSkill)) {
myparskill = {'_id': parseInt(idSkill)};
} else {
myparskill = {'_id': idSkill};
}
const query = [
let query = [
{
'$match': {
'$and': [
myparskill,
],
'_id': idSkill,
},
},
{
@@ -237,38 +200,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
note: 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -294,38 +226,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -351,38 +252,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
//'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
/*{
'$lookup': {
@@ -410,38 +280,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -466,40 +305,17 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYSKILLS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
query = [...query,
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
},
$project: this.getProject(objadd.proj),
}
];
return MySkill.aggregate(query).then((rec) => {
@@ -507,6 +323,24 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
});
};
MySkillSchema.statics.getProject = function (proj_add2) {
let proj = {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
idStatusSkill: 1,
website: 1,
'numLevel': 1,
//**ADDFIELD_MYSKILL
};
const proj_add = shared_consts.getProjectForAll(proj_add2)
return Object.assign({}, proj, proj_add);
}
MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
const MySkill = this;

View File

@@ -1602,6 +1602,8 @@ UserSchema.statics.getUserProfileByUsername = async function (
'profile.calc': 1,
'profile.handshake': 1,
'profile.friends': 1,
'profile.favorite': 1,
'profile.bookmark': 1,
email: 1,
date_reg: 1,
'useraport.username': 1,
@@ -1646,6 +1648,8 @@ UserSchema.statics.getUserProfileByUsername = async function (
'profile.calc': 1,
'profile.handshake': 1,
'profile.friends': 1,
'profile.favorite': 1,
'profile.bookmark': 1,
email: 1,
date_reg: 1,
'useraport.username': 1,
@@ -1691,6 +1695,8 @@ UserSchema.statics.getUserProfileByUsername = async function (
'profile.calc': 1,
'profile.handshake': 1,
'profile.friends': 1,
'profile.favorite': 1,
'profile.bookmark': 1,
'mycities': 1,
'comune': 1,
email: 1,
@@ -1898,7 +1904,7 @@ UserSchema.statics.removeReqFriend = async function (
// Rimuovo il Favorite
UserSchema.statics.removeFavorite = async function (
idapp, id, tab) {
idapp, username, id, tab) {
return await User.updateOne({ idapp, username },
{ $pull: { 'profile.favorite': { id: { $in: [id] }, tab } } });
};
@@ -1911,7 +1917,7 @@ UserSchema.statics.addFavorite = async function (
};
// Rimuovo il Bookmark
UserSchema.statics.removeBookmark = async function (
idapp, id, tab) {
idapp, username, id, tab) {
return await User.updateOne({ idapp, username },
{ $pull: { 'profile.bookmark': { id: { $in: [id] }, tab } } });
};
@@ -2774,7 +2780,9 @@ function getWhatToShow(idapp, username) {
date_reg: 1,
'profile.friends': 1,
'profile.handshake': 1,
};
'profile.favorite': 1,
'profile.bookmark': 1,
};
}
@@ -2797,7 +2805,9 @@ function getWhatToShow_Unknown(idapp, username) {
date_reg: 1,
'profile.handshake': 1,
'profile.friends': 1,
}
'profile.favorite': 1,
'profile.bookmark': 1,
}
}
UserSchema.statics.getWhatToShow_IfFriends = async function (idapp, username) {
@@ -2823,7 +2833,9 @@ UserSchema.statics.getWhatToShow_IfFriends = async function (idapp, username) {
groups: 1,
'profile.handshake': 1,
'profile.friends': 1,
};
'profile.favorite': 1,
'profile.bookmark': 1,
};
};