- 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

@@ -12,6 +12,8 @@ const { MyGroup } = require('./mygroup');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectId } = require('mongodb');
const tableModel = shared_consts.TABLES_MYHOSPS;
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true;
@@ -27,6 +29,7 @@ const MyHospSchema = new Schema({
required: true,
},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
groupname: { type: String },
visibile: {
type: Boolean
},
@@ -147,7 +150,7 @@ MyHospSchema.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),
},
};
@@ -202,7 +205,7 @@ MyHospSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
$project: this.getProject(),
$project: shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -228,7 +231,7 @@ MyHospSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
$project: this.getProject(),
$project: shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -254,7 +257,21 @@ MyHospSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
$project: this.getProject(),
$lookup: {
'from': 'mygroups',
'localField': 'groupname',
'foreignField': 'groupname',
'as': 'mygrp',
},
},
{
$unwind: {
path: '$mygrp',
preserveNullAndEmptyArrays: true,
},
},
{
$project: shared_consts.getProjectForAll({}, tableModel),
},
/*{
'$lookup': {
@@ -280,7 +297,7 @@ MyHospSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
$project: this.getProject(),
$project: shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -313,7 +330,7 @@ MyHospSchema.statics.getMyRecById = function (idapp, id) {
query = [...query, ...objadd.query];
const toadd = {
$project: this.getProject(objadd.proj),
$project: shared_consts.getProjectForAll(objadd.proj, tableModel),
};
query = [...query, { ...toadd }];