- 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_MYGOODS;
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true;
@@ -28,6 +30,7 @@ const MyGoodSchema = new Schema({
required: true,
},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
groupname: { type: String },
idSectorGood: {
type: Number,
},
@@ -143,7 +146,7 @@ MyGoodSchema.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),
},
};
@@ -201,7 +204,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
},
},
{
$project: this.getProject(),
$project: shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -227,7 +230,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
},
},
{
$project: this.getProject(),
$project: shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -254,7 +257,21 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
},
},
{
$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 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
},
},
{
$project: this.getProject(),
$project: shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -313,7 +330,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
query = [...query, ...objadd.query];
const toadd = {
$project: this.getProject(objadd.proj),
$project: shared_consts.getProjectForAll(objadd.proj, tableModel),
};
query = [...query, { ...toadd }];