- Categorie

- ProductInfo
This commit is contained in:
Surya Paolo
2023-12-27 02:58:15 +01:00
parent f0495d93b3
commit 15d831eecc
16 changed files with 516 additions and 230 deletions

56
src/server/models/catprod.js Executable file
View File

@@ -0,0 +1,56 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const tools = require('../tools/general');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const CatProdSchema = new Schema({
idapp: {
type: String,
},
name: {
type: String,
},
img: {
type: String,
},
});
CatProdSchema.statics.getAllCategories = function (callback) {
CatProd.find(callback)
}
CatProdSchema.statics.getCatProdById = function (id, callback) {
CatProd.findById(id, callback);
}
CatProdSchema.statics.getFieldsForSearch = function () {
return [{ field: 'name', type: tools.FieldType.string }]
};
CatProdSchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, idapp, params);
};
CatProdSchema.statics.findAllIdApp = async function (idapp) {
const myfind = { idapp };
return await CatProd.find(myfind).sort({ name: 1 });
};
const CatProd = mongoose.model('CatProd', CatProdSchema);
CatProd.createIndexes((err) => {
if (err) throw err;
});
module.exports = CatProd;