Zoom Calendar
This commit is contained in:
70
src/server/models/calzoom.js
Normal file
70
src/server/models/calzoom.js
Normal file
@@ -0,0 +1,70 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const CalZoomSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
lang: {
|
||||
type: String,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
},
|
||||
typeconf: {
|
||||
type: String,
|
||||
},
|
||||
date_start: {
|
||||
type: Date
|
||||
},
|
||||
date_end: {
|
||||
type: Date
|
||||
},
|
||||
id_conf_zoom: {
|
||||
type: String
|
||||
},
|
||||
note: {
|
||||
type: String
|
||||
}
|
||||
});
|
||||
|
||||
CalZoomSchema.statics.getFieldsForSearch = function () {
|
||||
return ['title']
|
||||
};
|
||||
|
||||
CalZoomSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
CalZoomSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const CalZoom = this;
|
||||
|
||||
const myfind = { idapp, date_start: { $gt: tools.IncDateNow(-1000 * 60 * 60 * 3) } };
|
||||
|
||||
return await CalZoom.find(myfind).sort({ date_start: 1 });
|
||||
};
|
||||
|
||||
CalZoomSchema.statics.getNextZoom = async function (idapp) {
|
||||
const CalZoom = this;
|
||||
|
||||
// const myfind = { idapp, $and: [{ date_start: { $gt: tools.IncDateNow(-1000 * 60 * 5) } }, { date_start: { $lt: tools.IncDateNow(1000 * 60 * 60 * 6) } }] } ;
|
||||
const myfind = { idapp, $and: [{ date_start: { $lt: tools.IncDateNow(1000 * 60 * 5) } }, { date_start: { $gt: tools.IncDateNow(-1000 * 60 * 60 * 2) } }] } ;
|
||||
|
||||
return await CalZoom.findOne(myfind).sort({ date_start: 1 });
|
||||
};
|
||||
|
||||
const CalZoom = mongoose.model('CalZoom', CalZoomSchema);
|
||||
|
||||
module.exports = { CalZoom };
|
||||
Reference in New Issue
Block a user