nuova veste grafica: myskills, mygoods, mybachecas, myhosps,
- cambiato id (da numero a stringa)
This commit is contained in:
@@ -10,91 +10,343 @@ let aggregation = [
|
||||
{
|
||||
$match: {
|
||||
idapp: "13",
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
date_updated: -1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
myId1: {
|
||||
$toObjectId: "$userId",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
localField: "myId1",
|
||||
foreignField: "_id",
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$user",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "goods",
|
||||
localField: "idGood",
|
||||
foreignField: "_id",
|
||||
as: "recGood",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$recGood",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "sectorgoods",
|
||||
localField: "idSectorGood",
|
||||
foreignField: "_id",
|
||||
as: "sectorGood",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$sectorGood",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "cities",
|
||||
localField: "idCity",
|
||||
foreignField: "_id",
|
||||
as: "mycities",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$mycities",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{
|
||||
deleted: {
|
||||
$exists: false,
|
||||
},
|
||||
$and: [
|
||||
{
|
||||
"profile.mygroups": {
|
||||
$elemMatch: {
|
||||
groupname: {
|
||||
$in: [
|
||||
"000017",
|
||||
"risoprova",
|
||||
"VillaggiamoItalia",
|
||||
"Terraw",
|
||||
"RisoBenevento",
|
||||
"111",
|
||||
"gruppodefaultriso",
|
||||
"pontiUmani",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
deleted: {
|
||||
$exists: true,
|
||||
$eq: false,
|
||||
},
|
||||
$or: [
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: true,
|
||||
$eq: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$and: [
|
||||
{
|
||||
"mycities.reg": "EMR",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: "$aportador_solidario",
|
||||
_id: null,
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: { "count": { $gte: 2 } }
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
count: -1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
let: {
|
||||
username: "$_id",
|
||||
idapp: "13",
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$$username",
|
||||
"$username",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$$idapp",
|
||||
"$idapp",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{ $unwind: "$user" },
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [ "$user", "$$ROOT" ],
|
||||
results: {
|
||||
$push: "$$ROOT",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0,
|
||||
count: 1,
|
||||
aportador_solidario: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
idapp: 1,
|
||||
"profile.img": 1,
|
||||
rows: {
|
||||
$slice: [
|
||||
"$results",
|
||||
0,
|
||||
10,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
db.users.aggregate(aggregation);
|
||||
db.myskills.aggregate(aggregation);
|
||||
|
||||
|
||||
431
mongodb/Favorite.mongodb
Normal file
431
mongodb/Favorite.mongodb
Normal file
@@ -0,0 +1,431 @@
|
||||
use('test_FreePlanet');
|
||||
|
||||
let aggregation = [
|
||||
{
|
||||
$match: {
|
||||
idapp: "13",
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
date_updated: -1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
let: {
|
||||
tab: 1,
|
||||
id: "$_id",
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$unwind: "$profile.favorite",
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$profile.favorite.id",
|
||||
"$$id",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$profile.favorite.tab",
|
||||
"$$tab",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$idapp",
|
||||
"13",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{ $project: { username: 1, _id: 0 } },
|
||||
],
|
||||
as: "myfav",
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
let: {
|
||||
tab: 1,
|
||||
id: "$_id",
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$unwind: "$profile.bookmark",
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$profile.bookmark.id",
|
||||
"$$id",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$profile.bookmark.tab",
|
||||
"$$tab",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: "mybook",
|
||||
},
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
myId1: {
|
||||
$toObjectId: "$userId",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
localField: "myId1",
|
||||
foreignField: "_id",
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$user",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recSkill: 1,
|
||||
sector: 1,
|
||||
idSector: 1,
|
||||
idSkill: 1,
|
||||
myskill: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
myfav: 1,
|
||||
mybook: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "skills",
|
||||
localField: "idSkill",
|
||||
foreignField: "_id",
|
||||
as: "recSkill",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$recSkill",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recSkill: 1,
|
||||
sector: 1,
|
||||
idSector: 1,
|
||||
idSkill: 1,
|
||||
myskill: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
myfav: 1,
|
||||
mybook: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "sectors",
|
||||
localField: "idSector",
|
||||
foreignField: "_id",
|
||||
as: "sector",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$sector",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recSkill: 1,
|
||||
sector: 1,
|
||||
idSector: 1,
|
||||
idSkill: 1,
|
||||
myskill: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
myfav: 1,
|
||||
mybook: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "cities",
|
||||
localField: "idCity",
|
||||
foreignField: "_id",
|
||||
as: "mycities",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$mycities",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recSkill: 1,
|
||||
sector: 1,
|
||||
idSector: 1,
|
||||
idSkill: 1,
|
||||
myskill: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
myfav: 1,
|
||||
mybook: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
"profile.mygroups": {
|
||||
$elemMatch: {
|
||||
groupname: {
|
||||
$in: [
|
||||
"000017",
|
||||
"risoprova",
|
||||
"VillaggiamoItalia",
|
||||
"Terraw",
|
||||
"RisoBenevento",
|
||||
"111",
|
||||
"gruppodefaultriso",
|
||||
"pontiUmani",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
$or: [
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: true,
|
||||
$eq: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$and: [
|
||||
{
|
||||
"mycities.reg": "EMR",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: null,
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
results: {
|
||||
$push: "$$ROOT",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
count: 1,
|
||||
rows: {
|
||||
$slice: [
|
||||
"$results",
|
||||
0,
|
||||
10,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
db.myskills.aggregate(aggregation);
|
||||
|
||||
352
mongodb/MySkills.mongodb
Normal file
352
mongodb/MySkills.mongodb
Normal file
@@ -0,0 +1,352 @@
|
||||
// MongoDB Playground
|
||||
// To disable this template go to Settings | MongoDB | Use Default Template For Playground.
|
||||
// Make sure you are connected to enable completions and to be able to run a playground.
|
||||
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
|
||||
|
||||
// Select the database to use.
|
||||
use('test_FreePlanet');
|
||||
|
||||
let aggregation = [
|
||||
{
|
||||
$match: {
|
||||
idapp: "13",
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
date_updated: -1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
myId1: {
|
||||
$toObjectId: "$userId",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
localField: "myId1",
|
||||
foreignField: "_id",
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$user",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "goods",
|
||||
localField: "idGood",
|
||||
foreignField: "_id",
|
||||
as: "recGood",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$recGood",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "sectorgoods",
|
||||
localField: "idSectorGood",
|
||||
foreignField: "_id",
|
||||
as: "sectorGood",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$sectorGood",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "cities",
|
||||
localField: "idCity",
|
||||
foreignField: "_id",
|
||||
as: "mycities",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$mycities",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
"profile.mygroups": {
|
||||
$elemMatch: {
|
||||
groupname: {
|
||||
$in: [
|
||||
"000017",
|
||||
"risoprova",
|
||||
"VillaggiamoItalia",
|
||||
"Terraw",
|
||||
"RisoBenevento",
|
||||
"111",
|
||||
"gruppodefaultriso",
|
||||
"pontiUmani",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
$or: [
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: true,
|
||||
$eq: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$and: [
|
||||
{
|
||||
"mycities.reg": "EMR",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: null,
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
results: {
|
||||
$push: "$$ROOT",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
count: 1,
|
||||
rows: {
|
||||
$slice: [
|
||||
"$results",
|
||||
0,
|
||||
10,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
db.myskills.aggregate(aggregation);
|
||||
|
||||
@@ -278,3 +278,11 @@ if (test) {
|
||||
// Use toArray() to exhaust the cursor to return the whole result set.
|
||||
// You can use hasNext()/next() to iterate through the cursor page by page.
|
||||
db.users.aggregate(aggregation);
|
||||
|
||||
|
||||
|
||||
db.getCollection('myskills').deleteMany({ '_id': { $lte: 10000 }})
|
||||
db.getCollection('mygoods').deleteMany({ '_id': { $lte: 10000 }})
|
||||
db.getCollection('mybachecas').deleteMany({ '_id': { $lte: 10000 }})
|
||||
db.getCollection('myhosps').deleteMany({ '_id': { $lte: 10000 }})
|
||||
db.getCollection('mygroups').deleteMany({ '_id': { $lte: 10000 }})
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1246,6 +1246,48 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
await City.remove({});
|
||||
await Province.remove({});
|
||||
|
||||
} else if (mydata.dbop === 'ConvTablesFromIntToString') {
|
||||
|
||||
const { MySkill } = require('../models/myskill');
|
||||
const { MyBacheca } = require('../models/mybacheca');
|
||||
const { MyHosp } = require('../models/myhosp');
|
||||
const { MyGood } = require('../models/mygood');
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
|
||||
console.log('INIZIO - Conversioni');
|
||||
// 'myskills',
|
||||
// 'mybachecas',
|
||||
// 'myhosps',
|
||||
// 'mygoods',
|
||||
// 'mygroups'
|
||||
|
||||
await ConvertiDaIntAStr(MySkill);
|
||||
await ConvertiDaIntAStr(MyBacheca);
|
||||
await ConvertiDaIntAStr(MyHosp);
|
||||
await ConvertiDaIntAStr(MyGood);
|
||||
await ConvertiDaIntAStr(MyGroup);
|
||||
|
||||
console.log('FINE - Conversioni');
|
||||
|
||||
} else if (mydata.dbop === 'Removeinteger') {
|
||||
|
||||
const { MySkill } = require('../models/myskill');
|
||||
const { MyBacheca } = require('../models/mybacheca');
|
||||
const { MyHosp } = require('../models/myhosp');
|
||||
const { MyGood } = require('../models/mygood');
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
|
||||
console.log('INIZIO - Rimozione');
|
||||
|
||||
await RimuoviInteri(MySkill);
|
||||
await RimuoviInteri(MyBacheca);
|
||||
await RimuoviInteri(MyHosp);
|
||||
await RimuoviInteri(MyGood);
|
||||
await RimuoviInteri(MyGroup);
|
||||
|
||||
console.log('FINE - Rimozione');
|
||||
|
||||
|
||||
} else if (mydata.dbop === 'createAllCircuits') {
|
||||
const { Province } = require('../models/province');
|
||||
|
||||
@@ -1318,6 +1360,77 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
}
|
||||
};
|
||||
|
||||
async function ConvertiDaIntAStr(mytable) {
|
||||
try {
|
||||
console.log('INIZIO - ConvertiDaIntAStr ', mytable.modelName);
|
||||
|
||||
return await mytable.find({ '_id': { $type: 16 } })
|
||||
.then(async (arr) => {
|
||||
console.log('num record ', arr.length)
|
||||
|
||||
let ind = 0;
|
||||
for (let x of arr) {
|
||||
|
||||
const idnew = x._id;
|
||||
|
||||
if (idnew < 10000) {
|
||||
|
||||
const idint = parseInt(x._id, 10) + 10000;
|
||||
|
||||
const myrec = new mytable(x._doc);
|
||||
|
||||
myrec._doc.date_created = x._doc.date_created;
|
||||
myrec._doc.date_updated = x._doc.date_updated;
|
||||
|
||||
if (!myrec._doc.date_updated) {
|
||||
if (myrec.hasOwnProperty('date_created'))
|
||||
myrec._doc.date_updated = myrec._doc.date_created;
|
||||
}
|
||||
if ((myrec.hasOwnProperty('date_updated') && !myrec._doc.date_created))
|
||||
myrec._doc.date_created = myrec._doc.date_updated;
|
||||
myrec._doc._id = idint + '';
|
||||
|
||||
let ris = await myrec.save((async function (err, doc) {
|
||||
if (doc) {
|
||||
ind++;
|
||||
//await mytable.findOneAndRemove({ _id: parseInt(doc._id, 10) });
|
||||
console.log('++Add (', ind, ')', doc._id);
|
||||
} else {
|
||||
const myid = parseInt(err.keyValue._id, 10) + 0;
|
||||
const canc = await mytable.findOneAndRemove({ _id: myid });
|
||||
if (canc)
|
||||
console.log('err', err.message, 'canc', canc._doc._id);
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
console.log('FINE - ConvertiDaIntAStr ', mytable.modelName);
|
||||
});
|
||||
|
||||
|
||||
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
async function RimuoviInteri(mytable) {
|
||||
try {
|
||||
console.log('INIZIO - RimuoviInteri ', mytable.modelName);
|
||||
|
||||
const arr = await mytable.find({ '_id': { $lte: 10000 } })
|
||||
console.log(' search interi...', arr.length);
|
||||
|
||||
const ris = await mytable.deleteMany({ '_id': { $lte: 10000 } })
|
||||
|
||||
console.log('FINE - RimuoviInteri ', mytable.modelName, ris);
|
||||
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
async function eseguiDbOpUser(idapp, mydata, locale, req, res) {
|
||||
|
||||
let ris = await User.DbOp(idapp, mydata);
|
||||
@@ -1451,15 +1564,19 @@ router.post('/cmd', authenticate, async (req, res) => {
|
||||
let ris = null;
|
||||
|
||||
if (cmd === shared_consts.CMD_USER.SET_FAVORITE) {
|
||||
if (value)
|
||||
ris = await User.addFavorite(idapp, username, id, tab);
|
||||
else
|
||||
ris = await User.removeFavorite(idapp, username, id, tab);
|
||||
if (tab) {
|
||||
if (value)
|
||||
ris = await User.addFavorite(idapp, username, id, tab);
|
||||
else
|
||||
ris = await User.removeFavorite(idapp, username, id, tab);
|
||||
}
|
||||
} else if (cmd === shared_consts.CMD_USER.SET_BOOKMARK) {
|
||||
if (value)
|
||||
ris = await User.addBookmark(idapp, username, id, tab);
|
||||
else
|
||||
ris = await User.removeBookmark(idapp, username, id, tab);
|
||||
if (tab) {
|
||||
if (value)
|
||||
ris = await User.addBookmark(idapp, username, id, tab);
|
||||
else
|
||||
ris = await User.removeBookmark(idapp, username, id, tab);
|
||||
}
|
||||
}
|
||||
|
||||
let state = (value && ris && ris.ok === 1) ? 1 : ((!value && ris && ris.ok === 1) ? -1 : 0);
|
||||
|
||||
@@ -3049,8 +3049,8 @@ class Telegram {
|
||||
let myarrmsg = mymsg.split(' ');
|
||||
if (myarrmsg.length > 0) {
|
||||
mymsg = myarrmsg[1];
|
||||
if (mymsg.startsWith('inv_')) {
|
||||
let arrparams = mymsg.split('_');
|
||||
if (mymsg.startsWith('inv#')) {
|
||||
let arrparams = mymsg.split('#');
|
||||
if (arrparams.length > 2) {
|
||||
invitante = arrparams[1];
|
||||
regexpire = arrparams[3];
|
||||
|
||||
@@ -1765,6 +1765,11 @@ module.exports = {
|
||||
return myquery;
|
||||
},
|
||||
|
||||
getNumTabByTable(table) {
|
||||
const myrec = shared_consts.MYTABS.find((rec) => rec.table === table)
|
||||
return myrec ? myrec.id : -1
|
||||
},
|
||||
|
||||
getGroupnameLookupPipeLine(params, proj) {
|
||||
|
||||
let myquery = [
|
||||
@@ -1796,7 +1801,7 @@ module.exports = {
|
||||
return myquery;
|
||||
},
|
||||
|
||||
getLookup: function (params, num, pass_proj) {
|
||||
getLookup: function (params, num, pass_proj, proj_add) {
|
||||
const query = [];
|
||||
|
||||
if (!params)
|
||||
@@ -1819,6 +1824,8 @@ module.exports = {
|
||||
if (!!pass_proj) {
|
||||
proj = pass_proj;
|
||||
}
|
||||
proj = Object.assign({}, proj, proj_add);
|
||||
|
||||
query.push(
|
||||
{
|
||||
$lookup: {
|
||||
@@ -1910,6 +1917,77 @@ module.exports = {
|
||||
return myquery;
|
||||
},
|
||||
|
||||
addNumFavoriteAndBookmarkToQuery(idapp, numtab) {
|
||||
let query =
|
||||
[{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
let: {
|
||||
tab: numtab,
|
||||
id: '$_id',
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$unwind: '$profile.favorite',
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{ $eq: ['$profile.favorite.id', '$$id'] },
|
||||
{ $eq: ['$profile.favorite.tab', '$$tab'] },
|
||||
{ $eq: ['$idapp', idapp] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{ $project: { username: 1, name: 1, surname: 1, 'profile.resid_province': 1, 'profile.img': 1, 'profile.qualifica': 1 } },
|
||||
],
|
||||
as: 'myfav',
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
let: {
|
||||
tab: numtab,
|
||||
id: '$_id',
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$unwind: '$profile.bookmark',
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{ $eq: ['$profile.bookmark.id', '$$id'] },
|
||||
{ $eq: ['$profile.bookmark.tab', '$$tab'] },
|
||||
{ $eq: ['$idapp', idapp] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
username: 1, name: 1, surname: 1, 'profile.resid_province': 1, 'profile.img': 1,
|
||||
'profile.qualifica': 1,
|
||||
}
|
||||
},
|
||||
],
|
||||
as: 'mybook',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
proj = {
|
||||
myfav: 1,
|
||||
mybook: 1,
|
||||
};
|
||||
|
||||
return { query, proj };
|
||||
},
|
||||
|
||||
getQueryTable: async function (idapp, params, user) {
|
||||
|
||||
if (typeof params.startRow !== 'number') {
|
||||
@@ -2103,10 +2181,10 @@ module.exports = {
|
||||
if (params.options) {
|
||||
if (this.isBitActive(params.options,
|
||||
shared_consts.OPTIONS_SEARCH_ONLY_FULL_WORDS)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (params.filterextra) {
|
||||
if (params.filterextra.length > 0)
|
||||
query = [...query, ...params.filterextra]
|
||||
@@ -2352,23 +2430,34 @@ module.exports = {
|
||||
query.push({ $unwind: params.unwind0 });
|
||||
}
|
||||
|
||||
const q1 = this.getLookup(params.lookup1, 1, proj);
|
||||
let objadd = { query: [], proj: {} };
|
||||
|
||||
let numtab = this.getNumTabByTable(params.table);
|
||||
|
||||
if (params.options && this.isBitActive(params.options,
|
||||
shared_consts.OPTIONS_ADD_COUNT_FAVORITE)) {
|
||||
objadd = this.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
|
||||
query = [...query, ...objadd.query];
|
||||
}
|
||||
|
||||
|
||||
const q1 = this.getLookup(params.lookup1, 1, proj, objadd.proj);
|
||||
if (q1) query = [...query, ...q1];
|
||||
|
||||
if (params.unwind1) {
|
||||
query.push({ $unwind: params.unwind1 });
|
||||
}
|
||||
|
||||
const q2 = this.getLookup(params.lookup2, 2, proj);
|
||||
const q2 = this.getLookup(params.lookup2, 2, proj, objadd.proj);
|
||||
if (q2) query = [...query, ...q2];
|
||||
|
||||
const q3 = this.getLookup(params.lookup3, 3, proj);
|
||||
const q3 = this.getLookup(params.lookup3, 3, proj, objadd.proj);
|
||||
if (q3) query = [...query, ...q3];
|
||||
|
||||
const q4 = this.getLookup(params.lookup4, 4, proj);
|
||||
const q4 = this.getLookup(params.lookup4, 4, proj, objadd.proj);
|
||||
if (q4) query = [...query, ...q4];
|
||||
|
||||
const q5 = this.getLookup(params.lookup5, 5, proj);
|
||||
const q5 = this.getLookup(params.lookup5, 5, proj, objadd.proj);
|
||||
if (q5) query = [...query, ...q5];
|
||||
|
||||
if (params.filtersearch2) {
|
||||
@@ -2377,6 +2466,7 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let filteradmin = false;
|
||||
if (params.filtercustom) {
|
||||
let condition = {};
|
||||
@@ -2480,6 +2570,7 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (params.filter && params.fieldsearch_last) {
|
||||
const querytemp = this.getFilterParam(params.filter,
|
||||
params.fieldsearch_last);
|
||||
@@ -3776,4 +3867,5 @@ module.exports = {
|
||||
return `<a href='${link}'>${username}</a>`;
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -46,6 +46,7 @@ module.exports = {
|
||||
OPTIONS_SEARCH_ONLY_FULL_WORDS: 1,
|
||||
OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2,
|
||||
OPTIONS_SEARCH_USER_ALL_WORDS: 4,
|
||||
OPTIONS_ADD_COUNT_FAVORITE: 8,
|
||||
|
||||
FRIENDSCMD: {
|
||||
SETTRUST: 121,
|
||||
@@ -134,7 +135,12 @@ module.exports = {
|
||||
TABLES_MYGOODS: 'mygoods',
|
||||
TABLES_MYEVENTS: 'myevents',
|
||||
|
||||
MYTABS: ['none', 'myskills', 'mybachecas', 'myhosps', 'mygoods', 'myevents'],
|
||||
MYTABS: [{id: 0, table: 'none' },
|
||||
{id: 1, table: 'myskills'},
|
||||
{id: 2, table: 'mybachecas' },
|
||||
{id: 3, table: 'myhosps'} ,
|
||||
{id: 4, table: 'mygoods'},
|
||||
{id: 5, table: 'myevents'}],
|
||||
|
||||
CMD_USER: {
|
||||
SET_FAVORITE: 1,
|
||||
@@ -149,6 +155,7 @@ module.exports = {
|
||||
//++Todo: per abilitare gli utenti ad inserire un Circuito aggiungere 'circuits' alla lista TABLES_PERM_NEWREC
|
||||
TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups', 'myhosps'],
|
||||
TABLES_REC_ID: ['skills', 'goods', 'subskills'],
|
||||
TABLES_FAVORITE_BOOKMARK: ['myskills', 'mygoods', 'mybachecas', 'myhosps'],
|
||||
|
||||
TABLES_VISU_STAT_IN_HOME: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'mygroups', 'circuits'],
|
||||
|
||||
@@ -533,4 +540,41 @@ module.exports = {
|
||||
SCOPERTO_MAX_CONTO_COMUNITARIO: 1000,
|
||||
},
|
||||
|
||||
getProjectForAll(proj_add) {
|
||||
let proj = {
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
'profile.img': 1,
|
||||
'profile.mygroups': 1,
|
||||
'profile.mycircuits': 1,
|
||||
'profile.qualifica': 1,
|
||||
'profile.resid_province': 1,
|
||||
'profile.username_telegram': 1,
|
||||
'profile.favorite': 1,
|
||||
'profile.bookmark': 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
};
|
||||
|
||||
if (proj_add)
|
||||
proj = Object.assign({}, proj, proj_add);
|
||||
|
||||
return proj;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user