- prima bozza catalogo

This commit is contained in:
Surya Paolo
2024-12-02 19:37:53 +01:00
parent 351b81308a
commit c914555a5f
6 changed files with 295 additions and 84 deletions

View 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 ImportaDescrSchema = new Schema({
idapp: {
type: String,
},
_id: {
type: String,
},
});
var ImportaDescr = module.exports = mongoose.model('ImportaDescr', ImportaDescrSchema);
ImportaDescrSchema.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.getImportaDescrByCode = function (idapp, code) {
return ImportaDescr.findAllIdApp(idapp, code);
}
module.exports.getImportaDescrById = async function (id) {
const arrris = await ImportaDescr.findAllIdApp('', '', id);
return arrris && arrris.length > 0 ? arrris[0] : null
}
module.exports.findAllIdApp = async function (idapp) {
const ImportaDescr = this;
const myfind = { idapp, deleted: false };
return await ImportaDescr.find(myfind, (err, arrrec) => {
return arrrec;
});
};

View 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 ImportaIsbnSchema = new Schema({
idapp: {
type: String,
},
_id: {
type: String,
},
});
var ImportaIsbn = module.exports = mongoose.model('ImportaIsbn', ImportaIsbnSchema);
ImportaIsbnSchema.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.getImportaIsbnByCode = function (idapp, code) {
return ImportaIsbn.findAllIdApp(idapp, code);
}
module.exports.getImportaIsbnById = async function (id) {
const arrris = await ImportaIsbn.findAllIdApp('', '', id);
return arrris && arrris.length > 0 ? arrris[0] : null
}
module.exports.findAllIdApp = async function (idapp) {
const ImportaIsbn = this;
const myfind = { idapp, deleted: false };
return await ImportaIsbn.find(myfind, (err, arrrec) => {
return arrrec;
});
};

View File

@@ -19,6 +19,9 @@ const productInfoSchema = new Schema({
department: {
type: String, ref: 'Department'
},
sku: {
type: String,
},
code: {
type: String,
unique: true,