- Load Events
- Edit Events - When a field is updated: undate also memory list record - Duplicate Event
This commit is contained in:
@@ -29,8 +29,8 @@ const MyEventSchema = new Schema({
|
||||
details: {
|
||||
type: String,
|
||||
},
|
||||
time: {
|
||||
type: String,
|
||||
withtime: {
|
||||
type: Boolean,
|
||||
},
|
||||
dur: {
|
||||
type: Number,
|
||||
@@ -103,66 +103,17 @@ const MyEventSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
MyEventSchema.statics.findAllByUserIdAndIdApp = function (userId, idapp, sall) {
|
||||
MyEventSchema.statics.findAllIdApp = function (idapp) {
|
||||
const Event = this;
|
||||
|
||||
let myfind = {};
|
||||
if (sall === '1')
|
||||
myfind = { idapp, booked: true };
|
||||
else
|
||||
myfind = { userId, idapp, booked: true };
|
||||
const myfind = { idapp };
|
||||
|
||||
return Event.find(myfind, (err, arrbooked) => {
|
||||
// console.log('ris MyEvent:', arrbooked);
|
||||
return arrbooked
|
||||
return Event.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
function getUsersByEvent(idapp) {
|
||||
const query = [
|
||||
{
|
||||
$match: { idapp }
|
||||
},
|
||||
{
|
||||
$group: { _id: "$userId" }
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: {
|
||||
$toString: "$userId"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
$Lookup: {
|
||||
from: "users",
|
||||
localField: "userId", // field in my collection
|
||||
foreignField: "ObjectId(_id)", // field in the 'from' collection
|
||||
as: "fromItems"
|
||||
}
|
||||
},
|
||||
{
|
||||
$replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ["$fromItems", 0] },] } }
|
||||
},
|
||||
{ $project: { username: 1, name: 1, surname: 1 } }
|
||||
|
||||
];
|
||||
return query
|
||||
}
|
||||
|
||||
|
||||
MyEventSchema.statics.findAllDistinctByEvent = function (idapp) {
|
||||
const Event = this;
|
||||
|
||||
const query = getUsersByEvent(idapp);
|
||||
|
||||
return Event.aggregate(query)
|
||||
.then(ris => {
|
||||
return ris
|
||||
});
|
||||
};
|
||||
|
||||
MyEventSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
@@ -58,6 +58,16 @@ OperatorSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
OperatorSchema.statics.findAllIdApp = function (idapp) {
|
||||
const Operator = this;
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return Operator.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
|
||||
const Operator = mongoose.model('Operator', OperatorSchema);
|
||||
|
||||
module.exports = { Operator };
|
||||
|
||||
Reference in New Issue
Block a user