- Iscrizione Conacreis

This commit is contained in:
Paolo Arena
2021-06-04 10:07:57 +02:00
parent cf97870cc7
commit 9d5eda50ae
20 changed files with 3048 additions and 1525 deletions

View File

@@ -19,6 +19,10 @@ const IscrittiConacreisSchema = new Schema({
userId: {
type: String,
},
numTesseraInterna: {
type: Number,
default: 0,
},
name: {
type: String,
trim: true,
@@ -81,6 +85,9 @@ const IscrittiConacreisSchema = new Schema({
metodo_pagamento: {
type: Number,
},
ha_pagato: {
type: Boolean,
},
iscrizione_compilata: {
type: Boolean,
},
@@ -120,6 +127,20 @@ const IscrittiConacreisSchema = new Schema({
});
IscrittiConacreisSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await IscrittiConacreis.findOne().limit(1).sort({ numTesseraInterna: -1 });
if (!!myrec) {
this.numTesseraInterna = myrec._doc.numTesseraInterna + 1;
} else {
this.numTesseraInterna = 0;
}
}
next();
});
var IscrittiConacreis = module.exports = mongoose.model('IscrittiConacreis', IscrittiConacreisSchema);
module.exports.getFieldsForSearch = function () {
@@ -128,6 +149,8 @@ module.exports.getFieldsForSearch = function () {
{ field: 'email', type: tools.FieldType.string }]
};
module.exports.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);