- Iscrizione Conacreis

This commit is contained in:
Paolo Arena
2021-05-10 01:50:40 +02:00
parent e05bbb39ee
commit cf97870cc7
16 changed files with 336 additions and 103 deletions

View File

@@ -0,0 +1,71 @@
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const CashSubCategorySchema = new Schema({
idapp: {
type: String,
},
idCashCategory: {
type: String,
},
descr: {
type: String,
},
notes: {
type: String
},
});
var CashSubCategory = module.exports = mongoose.model('CashSubCategory', CashSubCategorySchema);
module.exports.getFieldsForSearch = function () {
return []
};
module.exports.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};
module.exports.findAllIdApp = async function (idapp) {
const myfind = { idapp };
return await CashSubCategory.find(myfind);
};
module.exports.getAllCashSubCategory = function (query, sort, callback) {
CashSubCategory.find(query, null, sort, callback)
}
module.exports.getCashSubCategoryByUserId = function (userId, sort, callback) {
CashSubCategory.find({ userId }, null, sort, callback)
}
module.exports.getCashSubCategoryByID = function (id, callback) {
CashSubCategory.findById(id, callback);
}
module.exports.createCashSubCategory = async function (CashSubCategory) {
const CashSubCategoryModel = new CashSubCategory(CashSubCategory);
return await CashSubCategoryModel.save(CashSubCategory)
.then((ris) => {
if (!!ris)
return ris._id;
return null;
});
}