Files
freeplanet_serverside/src/server/models/category.js
Surya Paolo 6270991b76 - Conversione Codice... Errore Service Worker regostration.
- Sistemare quasar.config.ts di piuchebuono!
-Le categorie non si vedono piu !!
2025-03-06 01:23:56 +01:00

60 lines
1.2 KiB
JavaScript
Executable File

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 CategorySchema = new Schema({
idapp: {
type: String,
},
name: {
type: String,
unique: true,
index: true,
},
img: {
type: String,
},
});
CategorySchema.statics.getAllCategories = function (callback) {
Category.find(callback)
}
CategorySchema.statics.getCategoryById = function (id, callback) {
Category.findById(id, callback);
}
CategorySchema.statics.getFieldsForSearch = function () {
return [{ field: 'name', type: tools.FieldType.string }]
};
CategorySchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, idapp, params);
};
CategorySchema.statics.findAllIdApp = async function (idapp) {
const myfind = { idapp };
return await Category.find(myfind).lean();
};
const Category = mongoose.model('Category', CategorySchema);
Category.createIndexes()
.then(() => { })
.catch((err) => { throw err; });
module.exports = { Category };