- Table of Disciplines #101

- Insert Facebook bar to the Site #97
This commit is contained in:
Paolo Arena
2019-11-12 21:34:03 +01:00
parent 0d776589f0
commit 049e882210
8 changed files with 115 additions and 1 deletions

View File

@@ -24,7 +24,12 @@ const ContribtypeSchema = new Schema({
}
});
ContribtypeSchema.statics.getFieldsForSearch = function () {
return ['label']
};
ContribtypeSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};

View File

@@ -0,0 +1,88 @@
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const DisciplineSchema = new Schema({
idapp: {
type: String,
},
order: {
type: Number,
},
typol_code: {
type: String,
},
label: {
type: String,
},
description: {
type: String,
},
linkpage: {
type: String,
},
color: {
type: String,
},
icon: {
type: String,
},
img_small: {
type: String,
},
img: {
type: String,
},
showinnewsletter: {
type: Boolean,
},
showinhome: {
type: Boolean,
},
teachers: [{
username: {
type: String,
}
}],
});
DisciplineSchema.statics.findAllIdApp = function (idapp) {
const Discipline = this;
const query = [
{ $match: { idapp } },
{ $sort: { order: 1 } }
];
return Discipline
.aggregate(query)
.then((arrrec) => {
return arrrec
})
};
DisciplineSchema.statics.getFieldsForSearch = function () {
return ['label', 'description']
};
DisciplineSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};
const Discipline = mongoose.model('Discipline', DisciplineSchema);
module.exports = { Discipline };

View File

@@ -88,6 +88,10 @@ OperatorSchema.statics.getEmailByUsername = async function (idapp, username) {
});
};
OperatorSchema.statics.getFieldsForSearch = function () {
return ['name', 'surname', 'email', 'cell']
};
OperatorSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();

View File

@@ -41,6 +41,7 @@ PermissionSchema.pre('save', async function (next) {
});
PermissionSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, 0, params);
};

View File

@@ -33,7 +33,12 @@ const SettingsSchema = new Schema({
}
});
SettingsSchema.statics.getFieldsForSearch = function () {
return ['key', 'value_str']
};
SettingsSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};

View File

@@ -30,7 +30,12 @@ const WhereSchema = new Schema({
},
});
WhereSchema.statics.getFieldsForSearch = function () {
return ['placename']
};
WhereSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};