- Iscrizione Conacreis
- Ordini - Carrello
This commit is contained in:
160
src/server/models/iscrittiConacreis.js
Executable file
160
src/server/models/iscrittiConacreis.js
Executable file
@@ -0,0 +1,160 @@
|
||||
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 IscrittiConacreisSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
userId: {
|
||||
type: String,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
surname: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
fiscalcode: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
residency_address: {
|
||||
type: String,
|
||||
},
|
||||
residency_city: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
residency_province: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
residency_country: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
residency_zipcode: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
dateofbirth: {
|
||||
type: Date,
|
||||
},
|
||||
cell_phone: {
|
||||
type: String,
|
||||
},
|
||||
newsletter_on: {
|
||||
type: Boolean,
|
||||
},
|
||||
accetta_carta_costituzionale_on: {
|
||||
type: Boolean,
|
||||
},
|
||||
terms: {
|
||||
type: Boolean,
|
||||
},
|
||||
iscrizione_compilata: {
|
||||
type: Boolean,
|
||||
},
|
||||
dateofreg: {
|
||||
type: Date,
|
||||
},
|
||||
codiceConacreis: {
|
||||
type: String,
|
||||
},
|
||||
annoTesseramento: {
|
||||
type: Number
|
||||
},
|
||||
motivazioni: {
|
||||
type: String,
|
||||
},
|
||||
competenze_professionalita: {
|
||||
type: String,
|
||||
},
|
||||
cosa_potrei_offrire: {
|
||||
type: String,
|
||||
},
|
||||
cosa_vorrei_ricevere: {
|
||||
type: String,
|
||||
},
|
||||
altre_comunicazioni: {
|
||||
type: String,
|
||||
},
|
||||
come_ci_hai_conosciuto: {
|
||||
type: String,
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
var IscrittiConacreis = module.exports = mongoose.model('IscrittiConacreis', IscrittiConacreisSchema);
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'surname', type: tools.FieldType.string },
|
||||
{ field: 'email', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
module.exports.getLastRec = async function (idapp) {
|
||||
const lastrec = await IscrittiConacreis.find({ idapp }).sort({ dateofreg: -1 }).limit(1);
|
||||
if (!!lastrec) {
|
||||
return lastrec[0];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.getNameSurnameByEmail = async function (idapp, email) {
|
||||
return await IscrittiConacreis.findOne({
|
||||
idapp, email,
|
||||
}, { name: 1, surname: 1 })
|
||||
.then((rec) => {
|
||||
return (!!rec) ? `${rec.name} ${rec.surname}` : '';
|
||||
}).catch((e) => {
|
||||
console.error('getNameSurnameByUsername', e);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports.findByEmail = function (idapp, email) {
|
||||
|
||||
return IscrittiConacreis.findOne({
|
||||
'idapp': idapp,
|
||||
'email': email,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await IscrittiConacreis.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user