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: {
|
$match: {
|
||||||
idapp: "13",
|
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: [
|
$or: [
|
||||||
{
|
{
|
||||||
deleted: {
|
$and: [
|
||||||
$exists: false,
|
{
|
||||||
},
|
"profile.mygroups": {
|
||||||
|
$elemMatch: {
|
||||||
|
groupname: {
|
||||||
|
$in: [
|
||||||
|
"000017",
|
||||||
|
"risoprova",
|
||||||
|
"VillaggiamoItalia",
|
||||||
|
"Terraw",
|
||||||
|
"RisoBenevento",
|
||||||
|
"111",
|
||||||
|
"gruppodefaultriso",
|
||||||
|
"pontiUmani",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pub_to_share: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deleted: {
|
$or: [
|
||||||
$exists: true,
|
{
|
||||||
$eq: false,
|
pub_to_share: {
|
||||||
},
|
$exists: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pub_to_share: {
|
||||||
|
$exists: true,
|
||||||
|
$eq: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
$and: [
|
||||||
|
{
|
||||||
|
"mycities.reg": "EMR",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$group: {
|
$group: {
|
||||||
_id: "$aportador_solidario",
|
_id: null,
|
||||||
count: {
|
count: {
|
||||||
$sum: 1,
|
$sum: 1,
|
||||||
},
|
},
|
||||||
},
|
results: {
|
||||||
},
|
$push: "$$ROOT",
|
||||||
{
|
|
||||||
$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" ],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$project: {
|
$project: {
|
||||||
_id: 0,
|
|
||||||
count: 1,
|
count: 1,
|
||||||
aportador_solidario: 1,
|
rows: {
|
||||||
username: 1,
|
$slice: [
|
||||||
name: 1,
|
"$results",
|
||||||
surname: 1,
|
0,
|
||||||
lasttimeonline: 1,
|
10,
|
||||||
idapp: 1,
|
],
|
||||||
"profile.img": 1,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
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.
|
// 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.
|
// You can use hasNext()/next() to iterate through the cursor page by page.
|
||||||
db.users.aggregate(aggregation);
|
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) {
|
AccountSchema.pre('save', async function (next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
this.date_created = new Date();
|
if (!this.date_created)
|
||||||
|
this.date_created = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ mongoose.level = 'F';
|
|||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectID } = require('mongodb');
|
||||||
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
@@ -82,7 +83,6 @@ const MyBachecaSchema = new Schema({
|
|||||||
},
|
},
|
||||||
date_created: {
|
date_created: {
|
||||||
type: Date,
|
type: Date,
|
||||||
default: Date.now,
|
|
||||||
},
|
},
|
||||||
date_updated: {
|
date_updated: {
|
||||||
type: Date,
|
type: Date,
|
||||||
@@ -91,7 +91,8 @@ const MyBachecaSchema = new Schema({
|
|||||||
|
|
||||||
MyBachecaSchema.pre('save', async function (next) {
|
MyBachecaSchema.pre('save', async function (next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
this.date_created = new Date();
|
if (!this.date_created)
|
||||||
|
this.date_created = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@@ -136,39 +137,7 @@ MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
|
|||||||
lk_FF: '_id',
|
lk_FF: '_id',
|
||||||
lk_as: 'user',
|
lk_as: 'user',
|
||||||
af_objId_tab: 'myId',
|
af_objId_tab: 'myId',
|
||||||
lk_proj: {
|
lk_proj: this.getProject(),
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -181,22 +150,13 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
|||||||
const MyBacheca = this;
|
const MyBacheca = this;
|
||||||
|
|
||||||
let myparsid = {
|
let myparsid = {
|
||||||
$or: [
|
'_id': id,
|
||||||
{
|
|
||||||
'_id': parseInt(idGood)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'_id': idGood,
|
|
||||||
}]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const query = [
|
let query = [
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match':
|
||||||
'$and': [
|
myparsid,
|
||||||
myparsid,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match': {
|
||||||
@@ -239,40 +199,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
'$project': this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -298,40 +225,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
'$project': this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -357,40 +251,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
'$project': this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
/*{
|
/*{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -416,40 +277,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
'$project': this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$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 MyBacheca.aggregate(query).then((rec) => {
|
||||||
return rec ? rec[0] : null;
|
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) {
|
MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||||
const MyBacheca = this;
|
const MyBacheca = this;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectID } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
@@ -80,7 +82,6 @@ const MyGoodSchema = new Schema({
|
|||||||
},
|
},
|
||||||
date_created: {
|
date_created: {
|
||||||
type: Date,
|
type: Date,
|
||||||
default: Date.now,
|
|
||||||
},
|
},
|
||||||
date_updated: {
|
date_updated: {
|
||||||
type: Date,
|
type: Date,
|
||||||
@@ -89,18 +90,8 @@ const MyGoodSchema = new Schema({
|
|||||||
|
|
||||||
MyGoodSchema.pre('save', async function (next) {
|
MyGoodSchema.pre('save', async function (next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
const myrec = await MyGood.findOne().limit(1).sort({ _id: -1 });
|
if (!this.date_created)
|
||||||
if (!!myrec) {
|
this.date_created = new Date();
|
||||||
if (myrec._doc._id === 0)
|
|
||||||
this._id = 1;
|
|
||||||
else
|
|
||||||
this._id = myrec._doc._id + 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this._id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.date_created = new Date();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@@ -145,37 +136,7 @@ MyGoodSchema.statics.executeQueryTable = function (idapp, params, user) {
|
|||||||
lk_FF: '_id',
|
lk_FF: '_id',
|
||||||
lk_as: 'user',
|
lk_as: 'user',
|
||||||
af_objId_tab: 'myId',
|
af_objId_tab: 'myId',
|
||||||
lk_proj: {
|
lk_proj: this.getProject(),
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -188,22 +149,13 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
|||||||
const MyGood = this;
|
const MyGood = this;
|
||||||
|
|
||||||
let myparsid = {
|
let myparsid = {
|
||||||
$or: [
|
'_id': idGood,
|
||||||
{
|
|
||||||
'_id': parseInt(idGood)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'_id': idGood,
|
|
||||||
}]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const query = [
|
let query = [
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match':
|
||||||
'$and': [
|
|
||||||
myparsid,
|
myparsid,
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match': {
|
||||||
@@ -246,39 +198,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -304,39 +224,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -363,39 +251,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -421,39 +277,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$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': {
|
$project: this.getProject(objadd.proj),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return MyGood.aggregate(query).then((rec) => {
|
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);
|
const MyGood = mongoose.model('MyGood', MyGoodSchema);
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ mongoose.plugin(schema => {
|
|||||||
const MyGroupSchema = new Schema({
|
const MyGroupSchema = new Schema({
|
||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
|
default: function () {
|
||||||
|
return new ObjectID().toString();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -144,18 +147,8 @@ MyGroupSchema.statics.executeQueryTable = function (idapp, params, user) {
|
|||||||
|
|
||||||
MyGroupSchema.pre('save', async function (next) {
|
MyGroupSchema.pre('save', async function (next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
const myrec = await MyGroup.findOne().limit(1).sort({ _id: -1 });
|
if (!this.date_created)
|
||||||
if (!!myrec) {
|
this.date_created = new Date();
|
||||||
if (myrec._doc._id === 0)
|
|
||||||
this._id = 1;
|
|
||||||
else
|
|
||||||
this._id = myrec._doc._id + 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this._id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.date_created = new Date();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
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
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
@@ -21,7 +22,7 @@ const MyHospSchema = new Schema({
|
|||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
userId: {type: Schema.Types.ObjectId, ref: 'User'},
|
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||||
visibile: {
|
visibile: {
|
||||||
type: Boolean
|
type: Boolean
|
||||||
},
|
},
|
||||||
@@ -85,38 +86,27 @@ const MyHospSchema = new Schema({
|
|||||||
},
|
},
|
||||||
date_created: {
|
date_created: {
|
||||||
type: Date,
|
type: Date,
|
||||||
default: Date.now,
|
|
||||||
},
|
},
|
||||||
date_updated: {
|
date_updated: {
|
||||||
type: Date,
|
type: Date,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
MyHospSchema.pre('save', async function(next) {
|
MyHospSchema.pre('save', async function (next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
const myrec = await MyHosp.findOne().limit(1).sort({_id: -1});
|
if (!this.date_created)
|
||||||
if (!!myrec) {
|
this.date_created = new Date();
|
||||||
if (myrec._doc._id === 0)
|
|
||||||
this._id = 1;
|
|
||||||
else
|
|
||||||
this._id = myrec._doc._id + 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this._id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.date_created = new Date();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
MyHospSchema.statics.findAllIdApp = async function(idapp) {
|
MyHospSchema.statics.findAllIdApp = async function (idapp) {
|
||||||
const MyHosp = this;
|
const MyHosp = this;
|
||||||
|
|
||||||
const query = [
|
const query = [
|
||||||
{$match: {idapp}},
|
{ $match: { idapp } },
|
||||||
{$sort: {descr: 1}},
|
{ $sort: { descr: 1 } },
|
||||||
];
|
];
|
||||||
|
|
||||||
return await MyHosp.aggregate(query).then((arrrec) => {
|
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 [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
MyHospSchema.statics.getFieldsLastForSearch = function() {
|
MyHospSchema.statics.getFieldsLastForSearch = function () {
|
||||||
return [
|
return [
|
||||||
{field: 'descr', type: tools.FieldType.string},
|
{ field: 'descr', type: tools.FieldType.string },
|
||||||
{field: 'note', 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 = this.getFieldsForSearch();
|
||||||
params.fieldsearch_last = this.getFieldsLastForSearch();
|
params.fieldsearch_last = this.getFieldsLastForSearch();
|
||||||
|
|
||||||
@@ -147,69 +137,24 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
lk_FF: '_id',
|
lk_FF: '_id',
|
||||||
lk_as: 'user',
|
lk_as: 'user',
|
||||||
af_objId_tab: 'myId',
|
af_objId_tab: 'myId',
|
||||||
lk_proj: {
|
lk_proj: this.getProject(),
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
params = {...params, ...otherparams};
|
params = { ...params, ...otherparams };
|
||||||
|
|
||||||
return tools.executeQueryTable(this, idapp, params, user);
|
return tools.executeQueryTable(this, idapp, params, user);
|
||||||
};
|
};
|
||||||
|
|
||||||
MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
MyHospSchema.statics.getMyRecById = function (idapp, id) {
|
||||||
const MyHosp = this;
|
const MyHosp = this;
|
||||||
|
|
||||||
let myparsid = {
|
const myparsid = { '_id': id };
|
||||||
$or: [
|
|
||||||
{
|
|
||||||
'_id': parseInt(idGood)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'_id': idGood,
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (tools.isNumber(id)) {
|
let query = [
|
||||||
myparsid = {'_id': parseInt(id)};
|
|
||||||
} else {
|
|
||||||
myparsid = {'_id': id};
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = [
|
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match':
|
||||||
'$and': [
|
|
||||||
myparsid,
|
myparsid,
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match': {
|
||||||
@@ -252,35 +197,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -306,35 +223,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -360,35 +249,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
/*{
|
/*{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -414,35 +275,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$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': {
|
$project: this.getProject(objadd.proj),
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return MyHosp.aggregate(query).then((rec) => {
|
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;
|
const MyHosp = this;
|
||||||
|
|
||||||
return MyHosp.getMyRecById(idapp, id);
|
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);
|
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 tools = require('../tools/general');
|
||||||
|
|
||||||
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const {ObjectID} = require('mongodb');
|
const {ObjectID} = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
@@ -86,7 +88,6 @@ const MySkillSchema = new Schema({
|
|||||||
},
|
},
|
||||||
date_created: {
|
date_created: {
|
||||||
type: Date,
|
type: Date,
|
||||||
default: Date.now,
|
|
||||||
},
|
},
|
||||||
date_updated: {
|
date_updated: {
|
||||||
type: Date,
|
type: Date,
|
||||||
@@ -95,7 +96,8 @@ const MySkillSchema = new Schema({
|
|||||||
|
|
||||||
MySkillSchema.pre('save', async function(next) {
|
MySkillSchema.pre('save', async function(next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
this.date_created = new Date();
|
if (!this.date_created)
|
||||||
|
this.date_created = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@@ -139,36 +141,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
lk_FF: '_id',
|
lk_FF: '_id',
|
||||||
lk_as: 'user',
|
lk_as: 'user',
|
||||||
af_objId_tab: 'myId',
|
af_objId_tab: 'myId',
|
||||||
lk_proj: {
|
lk_proj: this.getProject(),
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -180,20 +153,10 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||||
const MySkill = this;
|
const MySkill = this;
|
||||||
|
|
||||||
let myparskill = {};
|
let query = [
|
||||||
|
|
||||||
if (tools.isNumber(idSkill)) {
|
|
||||||
myparskill = {'_id': parseInt(idSkill)};
|
|
||||||
} else {
|
|
||||||
myparskill = {'_id': idSkill};
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = [
|
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match': {
|
||||||
'$and': [
|
'_id': idSkill,
|
||||||
myparskill,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -237,38 +200,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -294,38 +226,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -351,38 +252,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
/*{
|
/*{
|
||||||
'$lookup': {
|
'$lookup': {
|
||||||
@@ -410,38 +280,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$project': {
|
$project: this.getProject(),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$lookup': {
|
'$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': {
|
$project: this.getProject(objadd.proj),
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return MySkill.aggregate(query).then((rec) => {
|
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) {
|
MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
|
||||||
const MySkill = this;
|
const MySkill = this;
|
||||||
|
|
||||||
|
|||||||
@@ -1602,6 +1602,8 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
|
'profile.favorite': 1,
|
||||||
|
'profile.bookmark': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
'useraport.username': 1,
|
'useraport.username': 1,
|
||||||
@@ -1646,6 +1648,8 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
|
'profile.favorite': 1,
|
||||||
|
'profile.bookmark': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
'useraport.username': 1,
|
'useraport.username': 1,
|
||||||
@@ -1691,6 +1695,8 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
|
'profile.favorite': 1,
|
||||||
|
'profile.bookmark': 1,
|
||||||
'mycities': 1,
|
'mycities': 1,
|
||||||
'comune': 1,
|
'comune': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
@@ -1898,7 +1904,7 @@ UserSchema.statics.removeReqFriend = async function (
|
|||||||
|
|
||||||
// Rimuovo il Favorite
|
// Rimuovo il Favorite
|
||||||
UserSchema.statics.removeFavorite = async function (
|
UserSchema.statics.removeFavorite = async function (
|
||||||
idapp, id, tab) {
|
idapp, username, id, tab) {
|
||||||
return await User.updateOne({ idapp, username },
|
return await User.updateOne({ idapp, username },
|
||||||
{ $pull: { 'profile.favorite': { id: { $in: [id] }, tab } } });
|
{ $pull: { 'profile.favorite': { id: { $in: [id] }, tab } } });
|
||||||
};
|
};
|
||||||
@@ -1911,7 +1917,7 @@ UserSchema.statics.addFavorite = async function (
|
|||||||
};
|
};
|
||||||
// Rimuovo il Bookmark
|
// Rimuovo il Bookmark
|
||||||
UserSchema.statics.removeBookmark = async function (
|
UserSchema.statics.removeBookmark = async function (
|
||||||
idapp, id, tab) {
|
idapp, username, id, tab) {
|
||||||
return await User.updateOne({ idapp, username },
|
return await User.updateOne({ idapp, username },
|
||||||
{ $pull: { 'profile.bookmark': { id: { $in: [id] }, tab } } });
|
{ $pull: { 'profile.bookmark': { id: { $in: [id] }, tab } } });
|
||||||
};
|
};
|
||||||
@@ -2774,7 +2780,9 @@ function getWhatToShow(idapp, username) {
|
|||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
};
|
'profile.favorite': 1,
|
||||||
|
'profile.bookmark': 1,
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2797,7 +2805,9 @@ function getWhatToShow_Unknown(idapp, username) {
|
|||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
}
|
'profile.favorite': 1,
|
||||||
|
'profile.bookmark': 1,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UserSchema.statics.getWhatToShow_IfFriends = async function (idapp, username) {
|
UserSchema.statics.getWhatToShow_IfFriends = async function (idapp, username) {
|
||||||
@@ -2823,7 +2833,9 @@ UserSchema.statics.getWhatToShow_IfFriends = async function (idapp, username) {
|
|||||||
groups: 1,
|
groups: 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.friends': 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 City.remove({});
|
||||||
await Province.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') {
|
} else if (mydata.dbop === 'createAllCircuits') {
|
||||||
const { Province } = require('../models/province');
|
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) {
|
async function eseguiDbOpUser(idapp, mydata, locale, req, res) {
|
||||||
|
|
||||||
let ris = await User.DbOp(idapp, mydata);
|
let ris = await User.DbOp(idapp, mydata);
|
||||||
@@ -1451,15 +1564,19 @@ router.post('/cmd', authenticate, async (req, res) => {
|
|||||||
let ris = null;
|
let ris = null;
|
||||||
|
|
||||||
if (cmd === shared_consts.CMD_USER.SET_FAVORITE) {
|
if (cmd === shared_consts.CMD_USER.SET_FAVORITE) {
|
||||||
if (value)
|
if (tab) {
|
||||||
ris = await User.addFavorite(idapp, username, id, tab);
|
if (value)
|
||||||
else
|
ris = await User.addFavorite(idapp, username, id, tab);
|
||||||
ris = await User.removeFavorite(idapp, username, id, tab);
|
else
|
||||||
|
ris = await User.removeFavorite(idapp, username, id, tab);
|
||||||
|
}
|
||||||
} else if (cmd === shared_consts.CMD_USER.SET_BOOKMARK) {
|
} else if (cmd === shared_consts.CMD_USER.SET_BOOKMARK) {
|
||||||
if (value)
|
if (tab) {
|
||||||
ris = await User.addBookmark(idapp, username, id, tab);
|
if (value)
|
||||||
else
|
ris = await User.addBookmark(idapp, username, id, tab);
|
||||||
ris = await User.removeBookmark(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);
|
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(' ');
|
let myarrmsg = mymsg.split(' ');
|
||||||
if (myarrmsg.length > 0) {
|
if (myarrmsg.length > 0) {
|
||||||
mymsg = myarrmsg[1];
|
mymsg = myarrmsg[1];
|
||||||
if (mymsg.startsWith('inv_')) {
|
if (mymsg.startsWith('inv#')) {
|
||||||
let arrparams = mymsg.split('_');
|
let arrparams = mymsg.split('#');
|
||||||
if (arrparams.length > 2) {
|
if (arrparams.length > 2) {
|
||||||
invitante = arrparams[1];
|
invitante = arrparams[1];
|
||||||
regexpire = arrparams[3];
|
regexpire = arrparams[3];
|
||||||
|
|||||||
@@ -1765,6 +1765,11 @@ module.exports = {
|
|||||||
return myquery;
|
return myquery;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getNumTabByTable(table) {
|
||||||
|
const myrec = shared_consts.MYTABS.find((rec) => rec.table === table)
|
||||||
|
return myrec ? myrec.id : -1
|
||||||
|
},
|
||||||
|
|
||||||
getGroupnameLookupPipeLine(params, proj) {
|
getGroupnameLookupPipeLine(params, proj) {
|
||||||
|
|
||||||
let myquery = [
|
let myquery = [
|
||||||
@@ -1796,7 +1801,7 @@ module.exports = {
|
|||||||
return myquery;
|
return myquery;
|
||||||
},
|
},
|
||||||
|
|
||||||
getLookup: function (params, num, pass_proj) {
|
getLookup: function (params, num, pass_proj, proj_add) {
|
||||||
const query = [];
|
const query = [];
|
||||||
|
|
||||||
if (!params)
|
if (!params)
|
||||||
@@ -1819,6 +1824,8 @@ module.exports = {
|
|||||||
if (!!pass_proj) {
|
if (!!pass_proj) {
|
||||||
proj = pass_proj;
|
proj = pass_proj;
|
||||||
}
|
}
|
||||||
|
proj = Object.assign({}, proj, proj_add);
|
||||||
|
|
||||||
query.push(
|
query.push(
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
@@ -1910,6 +1917,77 @@ module.exports = {
|
|||||||
return myquery;
|
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) {
|
getQueryTable: async function (idapp, params, user) {
|
||||||
|
|
||||||
if (typeof params.startRow !== 'number') {
|
if (typeof params.startRow !== 'number') {
|
||||||
@@ -2103,10 +2181,10 @@ module.exports = {
|
|||||||
if (params.options) {
|
if (params.options) {
|
||||||
if (this.isBitActive(params.options,
|
if (this.isBitActive(params.options,
|
||||||
shared_consts.OPTIONS_SEARCH_ONLY_FULL_WORDS)) {
|
shared_consts.OPTIONS_SEARCH_ONLY_FULL_WORDS)) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (params.filterextra) {
|
if (params.filterextra) {
|
||||||
if (params.filterextra.length > 0)
|
if (params.filterextra.length > 0)
|
||||||
query = [...query, ...params.filterextra]
|
query = [...query, ...params.filterextra]
|
||||||
@@ -2352,23 +2430,34 @@ module.exports = {
|
|||||||
query.push({ $unwind: params.unwind0 });
|
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 (q1) query = [...query, ...q1];
|
||||||
|
|
||||||
if (params.unwind1) {
|
if (params.unwind1) {
|
||||||
query.push({ $unwind: 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];
|
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];
|
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];
|
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 (q5) query = [...query, ...q5];
|
||||||
|
|
||||||
if (params.filtersearch2) {
|
if (params.filtersearch2) {
|
||||||
@@ -2377,6 +2466,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let filteradmin = false;
|
let filteradmin = false;
|
||||||
if (params.filtercustom) {
|
if (params.filtercustom) {
|
||||||
let condition = {};
|
let condition = {};
|
||||||
@@ -2480,6 +2570,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (params.filter && params.fieldsearch_last) {
|
if (params.filter && params.fieldsearch_last) {
|
||||||
const querytemp = this.getFilterParam(params.filter,
|
const querytemp = this.getFilterParam(params.filter,
|
||||||
params.fieldsearch_last);
|
params.fieldsearch_last);
|
||||||
@@ -3776,4 +3867,5 @@ module.exports = {
|
|||||||
return `<a href='${link}'>${username}</a>`;
|
return `<a href='${link}'>${username}</a>`;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ module.exports = {
|
|||||||
OPTIONS_SEARCH_ONLY_FULL_WORDS: 1,
|
OPTIONS_SEARCH_ONLY_FULL_WORDS: 1,
|
||||||
OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2,
|
OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2,
|
||||||
OPTIONS_SEARCH_USER_ALL_WORDS: 4,
|
OPTIONS_SEARCH_USER_ALL_WORDS: 4,
|
||||||
|
OPTIONS_ADD_COUNT_FAVORITE: 8,
|
||||||
|
|
||||||
FRIENDSCMD: {
|
FRIENDSCMD: {
|
||||||
SETTRUST: 121,
|
SETTRUST: 121,
|
||||||
@@ -134,7 +135,12 @@ module.exports = {
|
|||||||
TABLES_MYGOODS: 'mygoods',
|
TABLES_MYGOODS: 'mygoods',
|
||||||
TABLES_MYEVENTS: 'myevents',
|
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: {
|
CMD_USER: {
|
||||||
SET_FAVORITE: 1,
|
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
|
//++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_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups', 'myhosps'],
|
||||||
TABLES_REC_ID: ['skills', 'goods', 'subskills'],
|
TABLES_REC_ID: ['skills', 'goods', 'subskills'],
|
||||||
|
TABLES_FAVORITE_BOOKMARK: ['myskills', 'mygoods', 'mybachecas', 'myhosps'],
|
||||||
|
|
||||||
TABLES_VISU_STAT_IN_HOME: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'mygroups', 'circuits'],
|
TABLES_VISU_STAT_IN_HOME: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'mygroups', 'circuits'],
|
||||||
|
|
||||||
@@ -533,4 +540,41 @@ module.exports = {
|
|||||||
SCOPERTO_MAX_CONTO_COMUNITARIO: 1000,
|
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