Progetti
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user