- Catalogo: Aggiunta di Schede
This commit is contained in:
71
src/server/models/myscheda.js
Executable file
71
src/server/models/myscheda.js
Executable file
@@ -0,0 +1,71 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
const { ObjectID, ObjectId } = require('mongodb');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const scheletroScheda = {
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
name: { type: String },
|
||||
isTemplate: { type: Boolean },
|
||||
widthpag: { type: Number },
|
||||
width: { type: Number },
|
||||
height: { type: Number },
|
||||
widthscheda: { type: String },
|
||||
numschede_perRiga: { type: Number },
|
||||
numschede_perCol: { type: Number },
|
||||
margine_top: { type: Number },
|
||||
margine_pagina: { type: String },
|
||||
margine_riga: { type: String },
|
||||
text: { type: String },
|
||||
posiz_text: { type: Number },
|
||||
line_height: { type: Number },
|
||||
|
||||
productTypes: [{ type: Number }],
|
||||
excludeproductTypes: [{ type: Number }],
|
||||
editore: [{ type: String }],
|
||||
author: { type: String },
|
||||
sort: { type: Number },
|
||||
arrProdottiSpeciali: [{ type: String }],
|
||||
};
|
||||
|
||||
const MySchedaSchema = new Schema(
|
||||
scheletroScheda
|
||||
);
|
||||
|
||||
|
||||
MySchedaSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'name', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
MySchedaSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
MySchedaSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const MyScheda = this;
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await MyScheda.find(myfind);
|
||||
};
|
||||
|
||||
const MyScheda = mongoose.model('MyScheda', MySchedaSchema);
|
||||
|
||||
MyScheda.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { MyScheda, MySchedaSchema, scheletroScheda };
|
||||
Reference in New Issue
Block a user