- catalogo macro, importazione dati
This commit is contained in:
63
src/server/models/importamacro.js
Executable file
63
src/server/models/importamacro.js
Executable file
@@ -0,0 +1,63 @@
|
||||
mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
// A1P
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const ImportaMacroSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
_id: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
var ImportaMacro = module.exports = mongoose.model('ImportaMacro', ImportaMacroSchema);
|
||||
|
||||
ImportaMacroSchema.index({ idapp: 1 });
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'description', type: tools.FieldType.string },
|
||||
]
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
module.exports.getImportaMacroByCode = function (idapp, code) {
|
||||
return ImportaMacro.findAllIdApp(idapp, code);
|
||||
}
|
||||
|
||||
module.exports.getImportaMacroById = async function (id) {
|
||||
const arrris = await ImportaMacro.findAllIdApp('', '', id);
|
||||
return arrris && arrris.length > 0 ? arrris[0] : null
|
||||
}
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
const ImportaMacro = this;
|
||||
|
||||
const myfind = { idapp, deleted: false };
|
||||
|
||||
return await ImportaMacro.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
};
|
||||
@@ -53,6 +53,9 @@ const productSchema = new Schema({
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
sale_price: {
|
||||
type: Number,
|
||||
},
|
||||
price_acquistato: {
|
||||
type: Number,
|
||||
required: true,
|
||||
@@ -79,6 +82,9 @@ const productSchema = new Schema({
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
status: { //publish
|
||||
type: String,
|
||||
},
|
||||
stockBloccatiQty: { // Prenotati Bloccati
|
||||
type: Number,
|
||||
default: 0,
|
||||
|
||||
@@ -24,6 +24,9 @@ const productInfoSchema = new Schema({
|
||||
unique: true,
|
||||
required: true,
|
||||
},
|
||||
id_wp: { // id in wordpress
|
||||
type: String,
|
||||
},
|
||||
codice_EAN: {
|
||||
type: String,
|
||||
},
|
||||
@@ -67,7 +70,10 @@ const productInfoSchema = new Schema({
|
||||
icon: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
img: { // Se esiste img (sul server) visualizza questa, altrimenti vedi se esiste image_link
|
||||
type: String,
|
||||
},
|
||||
image_link: {
|
||||
type: String,
|
||||
},
|
||||
link_scheda: {
|
||||
@@ -91,6 +97,18 @@ const productInfoSchema = new Schema({
|
||||
note: {
|
||||
type: String,
|
||||
},
|
||||
author: {
|
||||
type: String,
|
||||
},
|
||||
collezione: {
|
||||
type: String,
|
||||
},
|
||||
publisher: { //editore
|
||||
type: String,
|
||||
},
|
||||
numpages: {
|
||||
type: Number,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user