Files
freeplanet_serverside/src/server/models/catai.js

63 lines
1.2 KiB
JavaScript
Raw Normal View History

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
return await CatAI.find(myfind).sort({ name: 1 });
};
const CatAI = mongoose.model('CatAI', CatAISchema);
CatAI.createIndexes()
.then(() => { })
.catch((err) => { throw err; });
2024-01-30 14:00:37 +01:00
module.exports = CatAI;