2024-01-30 14:00:37 +01:00
|
|
|
|
|
|
|
|
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 CatAISchema = new Schema({
|
|
|
|
|
name: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2025-02-06 19:00:02 +01:00
|
|
|
idapp: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2024-01-30 14:00:37 +01:00
|
|
|
img: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
icon: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
color: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
CatAISchema.statics.getAllCategories = function (callback) {
|
|
|
|
|
CatAI.find(callback)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CatAISchema.statics.getCatAIById = function (id, callback) {
|
|
|
|
|
CatAI.findById(id, callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CatAISchema.statics.getFieldsForSearch = function () {
|
|
|
|
|
return [{ field: 'name', type: tools.FieldType.string }]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CatAISchema.statics.executeQueryTable = function (idapp, params) {
|
|
|
|
|
return tools.executeQueryTable(this, idapp, params);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CatAISchema.statics.findAllIdApp = async function (idapp) {
|
2025-02-06 19:00:02 +01:00
|
|
|
const myfind = { idapp };
|
2024-01-30 14:00:37 +01:00
|
|
|
|
2025-03-06 01:23:56 +01:00
|
|
|
return await CatAI.find(myfind).sort({ name: 1 }).lean();
|
2024-01-30 14:00:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const CatAI = mongoose.model('CatAI', CatAISchema);
|
|
|
|
|
|
2025-03-03 00:46:08 +01:00
|
|
|
CatAI.createIndexes()
|
|
|
|
|
.then(() => { })
|
|
|
|
|
.catch((err) => { throw err; });
|
|
|
|
|
|
2024-01-30 14:00:37 +01:00
|
|
|
|
|
|
|
|
module.exports = CatAI;
|