- aggiunto anche nei beni, servizi e ospitalità la possibilità di aggiungerli come "Gruppo"

This commit is contained in:
Surya Paolo
2025-01-14 18:34:52 +01:00
parent 45be5038b9
commit 39784aeb0e
9 changed files with 110 additions and 36 deletions

View File

@@ -13,6 +13,8 @@ const shared_consts = require('../tools/shared_nodejs');
const { ObjectId } = require('mongodb');
const tableModel = shared_consts.TABLES_MYSKILLS;
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true;
@@ -32,6 +34,7 @@ const MySkillSchema = new Schema(
required: true,
},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
groupname: { type: String },
idSector: {
type: Number,
},
@@ -152,7 +155,7 @@ MySkillSchema.statics.executeQueryTable = function (idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: this.getProject(),
lk_proj: shared_consts.getProjectForAll({}, tableModel),
},
};
@@ -206,7 +209,7 @@ MySkillSchema.statics.getMyRecById = function (idapp, idSkill) {
},
},
{
$project: this.getProject(),
$project: shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -232,7 +235,7 @@ MySkillSchema.statics.getMyRecById = function (idapp, idSkill) {
},
},
{
$project: this.getProject(),
$project: shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -258,7 +261,21 @@ MySkillSchema.statics.getMyRecById = function (idapp, idSkill) {
},
},
{
$project: this.getProject(),
$lookup: {
'from': 'mygroups',
'localField': 'groupname',
'foreignField': 'groupname',
'as': 'mygrp',
},
},
{
$unwind: {
path: '$mygrp',
preserveNullAndEmptyArrays: true,
},
},
{
$project: shared_consts.getProjectForAll({}, tableModel),
},
/*{
'$lookup': {
@@ -286,7 +303,7 @@ MySkillSchema.statics.getMyRecById = function (idapp, idSkill) {
},
},
{
$project: this.getProject(),
$project: shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -319,7 +336,7 @@ MySkillSchema.statics.getMyRecById = function (idapp, idSkill) {
query = [...query, ...objadd.query];
const toadd = {
$project: this.getProject(objadd.proj),
$project: shared_consts.getProjectForAll(objadd.proj, tableModel),
};
query = [...query, { ...toadd }];