- Generazione della Raccolta dei Cataloghi (web e Stampa), e creazione del PDF Online.
- Lista Raccolta Cataloghi, aggiungi/togli catalogo.
This commit is contained in:
@@ -251,6 +251,28 @@ CatalogSchema.statics.findAllIdApp = async function (idapp) {
|
||||
}
|
||||
};
|
||||
|
||||
CatalogSchema.statics.executeQueryPickup = async function (idapp, params) {
|
||||
const strfind = params.search;
|
||||
|
||||
if (strfind === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Cerca title
|
||||
const reg = new RegExp(strfind, 'i');
|
||||
const arrrec = await this.find({
|
||||
idapp,
|
||||
title: reg,
|
||||
})
|
||||
.sort({ title: 1 })
|
||||
.limit(10)
|
||||
.select('title _id')
|
||||
.lean();
|
||||
|
||||
return arrrec;
|
||||
};
|
||||
|
||||
|
||||
const Catalog = mongoose.model('Catalog', CatalogSchema);
|
||||
|
||||
Catalog.createIndexes()
|
||||
|
||||
94
src/server/models/raccoltacataloghi.js
Executable file
94
src/server/models/raccoltacataloghi.js
Executable file
@@ -0,0 +1,94 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
const { ObjectId } = require('mongodb');
|
||||
|
||||
const { IImg } = require('../models/myscheda');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = 'F';
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin((schema) => {
|
||||
schema.options.usePushEach = true;
|
||||
});
|
||||
|
||||
const RaccoltaCataloghiSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
index: true,
|
||||
},
|
||||
foto_raccolta: IImg,
|
||||
|
||||
idPageAssigned: {
|
||||
type: String,
|
||||
},
|
||||
idPageAssigned_stampa: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
nomefile_da_generare: String,
|
||||
|
||||
pdf_generato: String,
|
||||
pdf_generato_stampa: String,
|
||||
data_generato: {
|
||||
type: Date,
|
||||
},
|
||||
data_generato_stampa: {
|
||||
type: Date,
|
||||
},
|
||||
pdf_online: String,
|
||||
data_online: {
|
||||
type: Date,
|
||||
},
|
||||
pdf_online_stampa: String,
|
||||
data_online_stampa: {
|
||||
type: Date,
|
||||
},
|
||||
|
||||
lista_cataloghi: [
|
||||
{
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: 'Catalog',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
RaccoltaCataloghiSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'title', type: tools.FieldType.string }];
|
||||
};
|
||||
|
||||
RaccoltaCataloghiSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
RaccoltaCataloghiSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const RaccoltaCataloghi = this;
|
||||
|
||||
try {
|
||||
let arrrec = await RaccoltaCataloghi.find({ idapp }).sort({ title: 1 }).populate('lista_cataloghi').lean();
|
||||
|
||||
return arrrec;
|
||||
} catch (err) {
|
||||
console.error('Errore: ', err);
|
||||
}
|
||||
};
|
||||
|
||||
const RaccoltaCataloghi = mongoose.model('RaccoltaCataloghi', RaccoltaCataloghiSchema);
|
||||
|
||||
RaccoltaCataloghi.createIndexes()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
module.exports = { RaccoltaCataloghi };
|
||||
Reference in New Issue
Block a user