++ aggiunta la prenotazione negli eventi. con la lista degli utenti.

This commit is contained in:
Surya Paolo
2023-04-17 00:11:36 +02:00
parent eea6e63c58
commit 0945f1af08
22 changed files with 636 additions and 157 deletions

View File

@@ -9,6 +9,8 @@ const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
const tableModel = shared_consts.TABLES_MYBACHECAS;
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true;
@@ -26,6 +28,7 @@ const MyBachecaSchema = new Schema({
required: true,
},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
groupname: { type: String },
idSector: {
type: Number,
},
@@ -51,6 +54,30 @@ const MyBachecaSchema = new Schema({
dateTimeEnd: {
type: Date,
},
organisedBy: {
type: String
},
contact_phone: {
type: String
},
contact_telegram: {
type: String
},
address: {
type: String,
},
min_partecip: {
type: Number,
},
max_partecip: {
type: Number,
},
link_maplocation: {
type: String,
},
contribstr: {
type: String,
},
numLevel: {
type: Number,
default: 0,
@@ -137,7 +164,7 @@ MyBachecaSchema.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),
},
};
@@ -151,25 +178,21 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
let myparsid = {
'_id': id,
idapp,
};
let query = [
{
'$match':
$match:
myparsid,
},
{
'$match': {
'idapp': idapp,
$sort: {
desc: 1,
},
},
{
'$sort': {
'desc': 1,
},
},
{
'$addFields': {
$addFields: {
'myId1': {
'$toObjectId': '$userId',
},
@@ -199,7 +222,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': this.getProject(),
'$project': shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -225,7 +248,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': this.getProject(),
'$project': shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -251,7 +274,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': this.getProject(),
'$project': shared_consts.getProjectForAll({}, tableModel),
},
/*{
'$lookup': {
@@ -277,7 +300,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': this.getProject(),
'$project': shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -304,42 +327,26 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYBACHECAS);
try {
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYBACHECAS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
query = query.push(
{
$project: this.getProject(objadd.proj),
}
);
const toadd = {
$project: shared_consts.getProjectForAll(objadd.proj, tableModel),
};
query = [...query, { ...toadd }];
} catch (e) {
console.error('e', e);
}
return MyBacheca.aggregate(query).then((rec) => {
return rec ? rec[0] : null;
});
};
MyBachecaSchema.statics.getProject = function (proj_add2) {
let proj = {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
// 'idSubSkill': 1,
idStatusSkill: 1,
idContribType: 1,
dateTimeStart: 1,
dateTimeEnd: 1,
website: 1,
//**ADDFIELD_MYBACHECAS
};
const proj_add = shared_consts.getProjectForAll(proj_add2)
return Object.assign({}, proj, proj_add);
}
MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
const MyBacheca = this;