- Iscrizione Conacreis
This commit is contained in:
71
src/server/models/cashSubCategory.js
Executable file
71
src/server/models/cashSubCategory.js
Executable 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;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user