aggiornamento Indici

This commit is contained in:
Surya Paolo
2023-12-09 11:55:58 +01:00
parent 502ed32c42
commit 023ba26003
81 changed files with 293 additions and 21 deletions

View File

@@ -741,4 +741,8 @@ AccountSchema.statics.updateSaldoAndTransato_AllAccounts = async function (idapp
const Account = mongoose.model('Account', AccountSchema);
Account.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Account };

View File

@@ -64,4 +64,8 @@ AdTypeSchema.statics.executeQueryTable = function(idapp, params) {
const AdType = mongoose.model('AdType', AdTypeSchema);
AdType.createIndexes((err) => {
if (err) throw err;
});
module.exports = {AdType};

View File

@@ -64,4 +64,8 @@ AdTypeGoodSchema.statics.executeQueryTable = function(idapp, params) {
const AdTypeGood = mongoose.model('AdTypeGood', AdTypeGoodSchema);
AdTypeGood.createIndexes((err) => {
if (err) throw err;
});
module.exports = {AdTypeGood};

View File

@@ -122,4 +122,8 @@ bookingSchema.statics.findAllDistinctByBooking = function (idapp) {
const Booking = mongoose.model('Booking', bookingSchema);
Booking.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Booking };

View File

@@ -76,4 +76,8 @@ BotSchema.statics.findAllIdApp = async function(idapp) {
const MyBot = mongoose.model('Bot', BotSchema);
MyBot.createIndexes((err) => {
if (err) throw err;
});
module.exports = {MyBot};

View File

@@ -76,4 +76,8 @@ CalZoomSchema.statics.getNextZoom = async function (idapp) {
const CalZoom = mongoose.model('CalZoom', CalZoomSchema);
CalZoom.createIndexes((err) => {
if (err) throw err;
});
module.exports = { CalZoom };

View File

@@ -31,6 +31,10 @@ const CartSchema = new Schema({
var Cart = module.exports = mongoose.model('Cart', CartSchema);
Cart.createIndexes((err) => {
if (err) throw err;
});
module.exports.findAllIdApp = async function (idapp, userId) {
const myfind = { idapp, userId };

View File

@@ -82,6 +82,10 @@ const CashSchema = new Schema({
var Cash = module.exports = mongoose.model('Cash', CashSchema);
Cash.createIndexes((err) => {
if (err) throw err;
});
module.exports.getFieldsForSearch = function () {
return []
};

View File

@@ -28,6 +28,10 @@ const CashCategorySchema = new Schema({
var CashCategory = module.exports = mongoose.model('CashCategory', CashCategorySchema);
CashCategory.createIndexes((err) => {
if (err) throw err;
});
module.exports.getFieldsForSearch = function () {
return []
};
@@ -66,3 +70,4 @@ module.exports.createCashCategory = async function (CashCategory) {
return null;
});
}

View File

@@ -69,3 +69,7 @@ module.exports.createCashSubCategory = async function (CashSubCategory) {
return null;
});
}
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -50,4 +50,9 @@ CategorySchema.statics.findAllIdApp = async function (idapp) {
const Category = mongoose.model('Category', CategorySchema);
Category.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Category };

View File

@@ -80,4 +80,8 @@ CatGrpSchema.statics.executeQueryTable = function (idapp, params) {
const CatGrp = mongoose.model('CatGrp', CatGrpSchema);
CatGrp.createIndexes((err) => {
if (err) throw err;
});
module.exports = { CatGrp };

View File

@@ -43,5 +43,9 @@ CfgServerSchema.statics.findAllIdApp = async function(idapp) {
const CfgServer = mongoose.model('CfgServer', CfgServerSchema);
CfgServer.createIndexes((err) => {
if (err) throw err;
});
module.exports = {CfgServer};

View File

@@ -1221,4 +1221,8 @@ CircuitSchema.statics.setFido = async function (idapp, username, circuitName, gr
const Circuit = mongoose.model('Circuit', CircuitSchema);
Circuit.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Circuit };

View File

@@ -201,4 +201,8 @@ CitySchema.statics.findAllIdApp = async function(idapp) {
const City = mongoose.model('City', CitySchema);
City.createIndexes((err) => {
if (err) throw err;
});
module.exports = {City};

View File

@@ -52,4 +52,8 @@ ContribtypeSchema.statics.findAllIdApp = async function (idapp) {
const Contribtype = mongoose.model('Contribtype', ContribtypeSchema);
Contribtype.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Contribtype };

View File

@@ -26,6 +26,10 @@ const departmentSchema = new Schema({
var Department = module.exports = mongoose.model('Department', departmentSchema);
module.exports.createIndexes((err) => {
if (err) throw err;
});
module.exports.getFieldsForSearch = function () {
return [{ field: 'name', type: tools.FieldType.string },
{ field: 'username', type: tools.FieldType.string }

View File

@@ -106,4 +106,8 @@ DisciplineSchema.statics.DuplicateAllRecords = async function (idapporig, idappd
const Discipline = mongoose.model('Discipline', DisciplineSchema);
Discipline.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Discipline };

View File

@@ -332,6 +332,9 @@ ExtraListSchema.statics.ImportData = async function (locale, idapp, strdata) {
const ExtraList = mongoose.model('ExtraList', ExtraListSchema);
ExtraList.createIndexes((err) => {
if (err) throw err;
});
module.exports = { ExtraList };

View File

@@ -64,4 +64,8 @@ GallerySchema.statics.findAllIdApp = async function (idapp) {
const Gallery = mongoose.model('Gallery', GallerySchema);
Gallery.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Gallery };

View File

@@ -80,4 +80,8 @@ GoodSchema.statics.executeQueryTable = function (idapp, params) {
const Good = mongoose.model('Good', GoodSchema);
Good.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Good };

View File

@@ -415,4 +415,8 @@ GraduatoriaSchema.statics.getPosizioneInGraduatoria = async function (idapp, ind
const Graduatoria = mongoose.model('Graduatoria', GraduatoriaSchema);
Graduatoria.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Graduatoria };

View File

@@ -47,3 +47,6 @@ module.exports.findAllIdApp = async function (idapp) {
return await Group.find(myfind);
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -228,3 +228,6 @@ module.exports.calculateHoursTodo = async function (idtodo) {
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -196,3 +196,7 @@ module.exports.findAllIdApp = async function(idapp) {
return arrrec;
});
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -196,3 +196,7 @@ module.exports.findAllIdApp = async function (idapp) {
return arrrec
});
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -73,4 +73,8 @@ LevelSchema.statics.executeQueryTable = function(idapp, params) {
const Level = mongoose.model('Level', LevelSchema);
Level.createIndexes((err) => {
if (err) throw err;
});
module.exports = {Level};

View File

@@ -121,4 +121,8 @@ MailingListSchema.statics.findByHash = function (idapp, hash) {
const MailingList = mongoose.model('MailingList', MailingListSchema);
MailingList.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MailingList };

View File

@@ -693,4 +693,8 @@ MovementSchema.statics.checkIfCoinsAlreadySent = async function (notifId) {
const Movement = mongoose.model('Movement', MovementSchema);
Movement.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Movement };

View File

@@ -125,4 +125,8 @@ MsgTemplateSchema.statics.findAllIdApp = async function (idapp) {
const MsgTemplate = mongoose.model('MsgTemplate', MsgTemplateSchema);
MsgTemplate.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MsgTemplate };

View File

@@ -378,4 +378,8 @@ MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
const MyBacheca = mongoose.model('MyBacheca', MyBachecaSchema);
MyBacheca.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyBacheca };

View File

@@ -210,4 +210,8 @@ MyElemSchema.statics.findAllIdApp = async function (idapp) {
const MyElem = mongoose.model('MyElem', MyElemSchema);
MyElem.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyElem };

View File

@@ -276,4 +276,8 @@ if (tools.INITDB_FIRSTIME) {
const MyEvent = mongoose.model('MyEvent', MyEventSchema);
MyEvent.createIndexes((err) => {
if (err) throw err;
});
module.exports = {MyEvent};

View File

@@ -348,4 +348,8 @@ MyGoodSchema.statics.getProject = function () {
const MyGood = mongoose.model('MyGood', MyGoodSchema);
MyGood.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyGood };

View File

@@ -643,4 +643,8 @@ MyGroupSchema.statics.setReceiveRisGroup = async function (idapp, groupname) {
const MyGroup = mongoose.model('MyGroup', MyGroupSchema);
MyGroup.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyGroup };

View File

@@ -348,4 +348,8 @@ MyHospSchema.statics.getProject = function () {
const MyHosp = mongoose.model('MyHosp', MyHospSchema);
MyHosp.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyHosp };

View File

@@ -218,4 +218,8 @@ MyPageSchema.statics.findInternalPages = async function (idapp) {
const MyPage = mongoose.model('MyPage', MyPageSchema);
MyPage.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyPage };

View File

@@ -354,4 +354,8 @@ MySkillSchema.statics.getCompleteRecord = function (idapp, id) {
const MySkill = mongoose.model('MySkill', MySkillSchema);
MySkill.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MySkill };

View File

@@ -170,4 +170,8 @@ NewstosentSchema.statics.isActivated = async function (_id) {
const Newstosent = mongoose.model('Newstosent', NewstosentSchema);
Newstosent.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Newstosent };

View File

@@ -118,4 +118,8 @@ OperatorSchema.statics.findAllIdApp = function (idapp) {
const Operator = mongoose.model('Operator', OperatorSchema);
Operator.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Operator };

View File

@@ -43,4 +43,8 @@ OpzEmailSchema.statics.findAllIdApp = async function (idapp) {
const OpzEmail = mongoose.model('OpzEmail', OpzEmailSchema);
OpzEmail.createIndexes((err) => {
if (err) throw err;
});
module.exports = { OpzEmail };

View File

@@ -1,7 +1,7 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
@@ -79,11 +79,17 @@ const orderSchema = new Schema({
var Order = module.exports = mongoose.model('Order', orderSchema);
module.exports.createIndexes((err) => {
if (err) throw err;
});
module.exports.getFieldsForSearch = function () {
return []
};
module.exports.executeQueryTable = function (idapp, params) {
const tools = require('../tools/general');
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};

View File

@@ -276,3 +276,7 @@ OrdersCartSchema.pre('save', async function (next) {
console.error(e.message);
}
});
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -45,4 +45,8 @@ PaymentTypeSchema.statics.findAllIdApp = async function (idapp) {
const PaymentType = mongoose.model('Paymenttype', PaymentTypeSchema);
PaymentType.createIndexes((err) => {
if (err) throw err;
});
module.exports = { PaymentType };

View File

@@ -57,4 +57,8 @@ PermissionSchema.statics.findAllIdApp = async function () {
const Permission = mongoose.model('Permission', PermissionSchema);
Permission.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Permission };

View File

@@ -100,3 +100,7 @@ module.exports.getProducerByID = function (id, callback) {
// const Producer = mongoose.model('Producer', producerSchema);
// module.exports = { Producer };
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -122,6 +122,8 @@ const productSchema = new Schema({
var Product = module.exports = mongoose.model('Product', productSchema);
productSchema.index({ idapp: 1 });
module.exports.getFieldsForSearch = function () {
return [{ field: 'name', type: tools.FieldType.string }]
};
@@ -211,6 +213,9 @@ module.exports.getProductByID = function (id, callback) {
Product.findById(id, callback);
}
module.exports.createIndexes((err) => {
if (err) throw err;
});
// const Product = mongoose.model('Product', ProductSchema);

View File

@@ -428,5 +428,9 @@ ProjectSchema.pre('save', function (next) {
var Project = mongoose.model('Projects', ProjectSchema);
Project.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Project };

View File

@@ -127,4 +127,8 @@ ProvinceSchema.statics.findAllIdApp = async function(idapp) {
const Province = mongoose.model('Province', ProvinceSchema);
Province.createIndexes((err) => {
if (err) throw err;
});
module.exports = {Province};

View File

@@ -433,4 +433,8 @@ reactionSchema.statics.removeBookmark = async function (
const Reaction = mongoose.model('Reaction', reactionSchema);
Reaction.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Reaction };

View File

@@ -42,4 +42,8 @@ searchSchema.statics.findAllByUserIdAndIdApp = function (userId, idapp, sall) {
const Search = mongoose.model('Search', searchSchema);
Search.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Search };

View File

@@ -80,4 +80,8 @@ SectorGoodSchema.statics.executeQueryTable = function (idapp, params) {
const SectorGood = mongoose.model('SectorGood', SectorGoodSchema);
SectorGood.createIndexes((err) => {
if (err) throw err;
});
module.exports = { SectorGood };

View File

@@ -109,4 +109,8 @@ sendmsgSchema.statics.findLastGroupByUserIdAndIdApp = function (userId, username
const SendMsg = mongoose.model('SendMsg', sendmsgSchema);
SendMsg.createIndexes((err) => {
if (err) throw err;
});
module.exports = { SendMsg };

View File

@@ -1220,4 +1220,8 @@ sendNotifSchema.statics.checkIfAlreadyExist = async function (idapp, tag, idpost
const SendNotif = mongoose.model('SendNotif', sendNotifSchema);
SendNotif.createIndexes((err) => {
if (err) throw err;
});
module.exports = { SendNotif: SendNotif };

View File

@@ -178,4 +178,8 @@ SettingsSchema.statics.getKeyNum = async function (idapp, key, mydefault) {
const Settings = mongoose.model('Settings', SettingsSchema);
Settings.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Settings };

View File

@@ -47,3 +47,6 @@ module.exports.findAllIdApp = async function (idapp) {
return await ShareWithUs.find(myfind);
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -1,8 +1,6 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const tools = require('../tools/general');
mongoose.Promise = global.Promise;
mongoose.level = "F";
@@ -217,7 +215,6 @@ module.exports.executeQueryTable = async function (idapp, params, userreq) {
}
};
module.exports.findAll = async function () {
@@ -357,3 +354,7 @@ module.exports.createFirstUserAdmin = async function () {
}
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -78,4 +78,8 @@ SkillSchema.statics.executeQueryTable = function (idapp, params) {
const Skill = mongoose.model('Skill', SkillSchema);
Skill.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Skill };

View File

@@ -75,4 +75,8 @@ StatusSkillSchema.statics.executeQueryTable = function (idapp, params) {
const StatusSkill = mongoose.model('StatusSkill', StatusSkillSchema);
StatusSkill.createIndexes((err) => {
if (err) throw err;
});
module.exports = { StatusSkill };

View File

@@ -59,3 +59,6 @@ module.exports.findAllIdApp = async function (idapp) {
return await Storehouse.find(myfind);
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -24,4 +24,8 @@ const SubscriberSchema = new Schema({
}
});
mongoose.model('subscribers', SubscriberSchema);
var Subscription = module.exports = mongoose.model('subscribers', SubscriberSchema);
Subscription.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -78,4 +78,8 @@ SubSkillSchema.statics.executeQueryTable = function (idapp, params) {
const SubSkill = mongoose.model('SubSkill', SubSkillSchema);
SubSkill.createIndexes((err) => {
if (err) throw err;
});
module.exports = { SubSkill };

View File

@@ -67,4 +67,8 @@ TemplEmailSchema.statics.findAllIdApp = async function (idapp) {
const TemplEmail = mongoose.model('TemplEmail', TemplEmailSchema);
TemplEmail.createIndexes((err) => {
if (err) throw err;
});
module.exports = { TemplEmail };

View File

@@ -519,5 +519,9 @@ TodoSchema.pre('save', function (next) {
var Todo = mongoose.model('Todos', TodoSchema);
Todo.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Todo };

View File

@@ -4721,7 +4721,7 @@ if (tools.INITDB_FIRSTIME) {
console.log(' createIndex User Index...');
UserSchema.index({ userId: 1 });
UserSchema.index({ 'idapp': 1 });
UserSchema.index({ idapp: 1 });
// UserSchema.index({ username: 'text', name: 'text', surname: 'text', email: 'text' });
@@ -5434,6 +5434,10 @@ UserSchema.statics.createNewSubRecord = async function (idapp, req) {
const User = mongoose.model('User', UserSchema);
User.createIndexes((err) => {
if (err) throw err;
});
class Hero {
constructor(name, level) {
this.name = name;

View File

@@ -95,4 +95,8 @@ UserRequestSchema.statics.findAllIdApp = async function (idapp) {
const UserRequest = mongoose.model('UserRequest', UserRequestSchema);
UserRequest.createIndexes((err) => {
if (err) throw err;
});
module.exports = { UserRequest };

View File

@@ -38,3 +38,7 @@ module.exports.getVariantProductByID = function(id, callback){
module.exports.getAllVariants = function(callback){
Variant.find(callback)
}
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -51,4 +51,8 @@ WhereSchema.statics.findAllIdApp = async function (idapp) {
const Where = mongoose.model('Where', WhereSchema);
Where.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Where };

View File

@@ -96,7 +96,7 @@ class Cart {
this.totalQty += order.quantity;
this.totalPrice += order.price * order.quantity;
}
this.totalPrice = parseFloat(this.totalPrice.toFixed(2))
}

View File

@@ -1,5 +1,5 @@
const mongoose = require('mongoose').set('debug', false)
const Subscription = mongoose.model('subscribers');
const Subscription = require('../../models/subscribers');
//const { ListaIngresso } = require('../../models/listaingresso');
const { Graduatoria } = require('../../models/graduatoria');

View File

@@ -99,6 +99,7 @@ router.post('/:userId', authenticate, async function (req, res, next) {
} catch (e) {
console.error('Err:', e);
return res.send({ code: server_constants.RIS_CODE_ERR, cart: 0 });
}

View File

@@ -11,7 +11,7 @@ var server_constants = require('../tools/server_constants');
var { authenticate, authenticate_noerror, auth_default } = require('../middleware/authenticate');
var mongoose = require('mongoose').set('debug', false);
const Subscription = mongoose.model('subscribers');
const Subscription = require('../models/subscribers');
const _ = require('lodash');
const { MyBacheca } = require('../models/mybacheca');

View File

@@ -10,7 +10,7 @@ var server_constants = require('../tools/server_constants');
var {authenticate, auth_default} = require('../middleware/authenticate');
var mongoose = require('mongoose').set('debug', false);
const Subscription = mongoose.model('subscribers');
const Subscription = require('../models/subscribers');
const _ = require('lodash');
const {MyGood} = require('../models/mygood');

View File

@@ -10,7 +10,7 @@ var server_constants = require('../tools/server_constants');
var {authenticate, auth_default} = require('../middleware/authenticate');
var mongoose = require('mongoose').set('debug', false);
const Subscription = mongoose.model('subscribers');
const Subscription = require('../models/subscribers');
const _ = require('lodash');
const {MySkill} = require('../models/myskill');

View File

@@ -12,7 +12,7 @@ var { Project } = require('../models/project');
var { authenticate, auth_default } = require('../middleware/authenticate');
var mongoose = require('mongoose').set('debug', false)
const Subscription = mongoose.model('subscribers');
const Subscription = require('../models/subscribers');
const _ = require('lodash');

View File

@@ -1,7 +1,7 @@
const express = require('express');
const router = express.Router();
const mongoose = require('mongoose').set('debug', false);
const Subscription = mongoose.model('subscribers');
const Subscription = require('../models/subscribers');
// const q = require('q');
const webpush = require('web-push');

View File

@@ -1,7 +1,7 @@
const express = require('express');
const router = express.Router();
const mongoose = require('mongoose').set('debug', false);
const Subscription = mongoose.model('subscribers');
const Subscription = require('../models/subscribers');
const tools = require('../tools/general');

View File

@@ -10,7 +10,7 @@ var { Project } = require('../models/project');
var { authenticate } = require('../middleware/authenticate');
var mongoose = require('mongoose').set('debug', false)
const Subscription = mongoose.model('subscribers');
const Subscription = require('../models/subscribers');
var { Todo } = require('../models/todo');
const { Settings } = require('../models/settings');

View File

@@ -43,7 +43,7 @@ const { Account } = require('../models/account');
const mongoose = require('mongoose').set('debug', false);
const Subscription = mongoose.model('subscribers');
const Subscription = require('../models/subscribers');
function existSubScribe(userId, access, browser) {
return Subscription.findOne({ userId, access, browser }).then(itemsub => {

View File

@@ -63,6 +63,7 @@ console.log('DB: ' + process.env.DATABASE);
var app = express();
let telegrambot = null;
const tools = require('./tools/general');

View File

@@ -10,8 +10,6 @@ require('../models/subscribers');
const printf = require('util').format;
const Site = require('../models/site');
const CryptoJS = require('crypto-js');
const Url = require('url-parse');
@@ -21,7 +19,7 @@ const { ObjectID, ObjectId } = require('mongodb');
const shared_consts = require('./shared_nodejs');
const mongoose = require('mongoose').set('debug', false);
const Subscription = mongoose.model('subscribers');
const Subscription = require('../models/subscribers');
const server_constants = require('./server_constants');
@@ -2952,14 +2950,14 @@ module.exports = {
startTimeLog(name) {
if (this.testing()) {
console.log('inizio', name);
// console.log('inizio', name);
console.time(name);
}
},
endTimeLog(name) {
if (this.testing()) {
console.log(' ... fine', name);
// console.log(' ... fine', name);
console.timeEnd(name);
}
},
@@ -3920,6 +3918,8 @@ module.exports = {
},
async loadApps() {
const Site = require('../models/site');
try {
this.MYAPPS = await Site.findAll(0);
// console.log('this.MYAPPS', this.MYAPPS);
@@ -3927,6 +3927,7 @@ module.exports = {
console.error('loadApps', e);
}
},
async getApps() {
if (this.MYAPPS.length <= 0)
await this.loadApps();