This commit is contained in:
Paolo Arena
2021-02-18 12:19:35 +01:00
parent 88ae9af12c
commit 14a3292da2
22 changed files with 233 additions and 122 deletions

View File

@@ -88,6 +88,27 @@ const MyEventSchema = new Schema({
canceled: {
type: Boolean,
},
lunchAvailable: {
type: Boolean,
},
dinnerAvailable: {
type: Boolean,
},
lunchType: {
type: Number,
},
dinnerType: {
type: Number,
},
lunchPrice: {
type: Number,
},
dinnerPrice: {
type: Number,
},
internal: {
type: Boolean,
},
deleted: {
type: Boolean,
},
@@ -99,13 +120,33 @@ const MyEventSchema = new Schema({
},
});
MyEventSchema.statics.findAllIdApp = function (idapp) {
MyEventSchema.statics.findAllIdApp = function (socioresidente, idapp) {
const Event = this;
const query = [
{ $match: { idapp } },
{ $sort: { dateTimeStart: 1 } }
];
let query = []
if (socioresidente) {
query = [
{
$match: {
idapp,
}
}
]
} else {
query = [
{
$match: {
idapp,
$or: [
{ $or: [{ internal: { $exists: false } }, { internal: { $exists: true, $eq: false } }] },
],
}
}
]
}
query.push({ $sort: { dateTimeStart: 1 } })
return Event
.aggregate(query)