|
|
|
|
@@ -6,7 +6,7 @@ mongoose.level = 'F';
|
|
|
|
|
|
|
|
|
|
const tools = require('../tools/general');
|
|
|
|
|
|
|
|
|
|
const {ObjectID} = require('mongodb');
|
|
|
|
|
const { ObjectID } = require('mongodb');
|
|
|
|
|
|
|
|
|
|
// Resolving error Unknown modifier: $pushAll
|
|
|
|
|
mongoose.plugin(schema => {
|
|
|
|
|
@@ -21,7 +21,7 @@ const MyBachecaSchema = new Schema({
|
|
|
|
|
type: String,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
userId: {type: Schema.Types.ObjectId, ref: 'User'},
|
|
|
|
|
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
|
|
|
|
idSector: {
|
|
|
|
|
type: Number,
|
|
|
|
|
},
|
|
|
|
|
@@ -86,9 +86,9 @@ const MyBachecaSchema = new Schema({
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MyBachecaSchema.pre('save', async function(next) {
|
|
|
|
|
MyBachecaSchema.pre('save', async function (next) {
|
|
|
|
|
if (this.isNew) {
|
|
|
|
|
const myrec = await MyBacheca.findOne().limit(1).sort({_id: -1});
|
|
|
|
|
const myrec = await MyBacheca.findOne().limit(1).sort({ _id: -1 });
|
|
|
|
|
if (!!myrec) {
|
|
|
|
|
if (myrec._doc._id === 0)
|
|
|
|
|
this._id = 1;
|
|
|
|
|
@@ -105,12 +105,12 @@ MyBachecaSchema.pre('save', async function(next) {
|
|
|
|
|
next();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MyBachecaSchema.statics.findAllIdApp = async function(idapp) {
|
|
|
|
|
MyBachecaSchema.statics.findAllIdApp = async function (idapp) {
|
|
|
|
|
const MyBacheca = this;
|
|
|
|
|
|
|
|
|
|
const query = [
|
|
|
|
|
{$match: {idapp}},
|
|
|
|
|
{$sort: {descr: 1}},
|
|
|
|
|
{ $match: { idapp } },
|
|
|
|
|
{ $sort: { descr: 1 } },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return await MyBacheca.aggregate(query).then((arrrec) => {
|
|
|
|
|
@@ -119,21 +119,21 @@ MyBachecaSchema.statics.findAllIdApp = async function(idapp) {
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MyBachecaSchema.statics.getFieldsForSearch = function() {
|
|
|
|
|
MyBachecaSchema.statics.getFieldsForSearch = function () {
|
|
|
|
|
return [];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MyBachecaSchema.statics.getFieldsLastForSearch = function() {
|
|
|
|
|
MyBachecaSchema.statics.getFieldsLastForSearch = function () {
|
|
|
|
|
return [
|
|
|
|
|
{field: 'note', type: tools.FieldType.string},
|
|
|
|
|
{field: 'descr', type: tools.FieldType.string},
|
|
|
|
|
{field: 'recSkill.descr', type: tools.FieldType.string},
|
|
|
|
|
{field: 'MyBacheca.descr', type: tools.FieldType.string},
|
|
|
|
|
{ field: 'note', type: tools.FieldType.string },
|
|
|
|
|
{ field: 'descr', type: tools.FieldType.string },
|
|
|
|
|
{ field: 'recSkill.descr', type: tools.FieldType.string },
|
|
|
|
|
{ field: 'MyBacheca.descr', type: tools.FieldType.string },
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MyBachecaSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|
|
|
|
MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
|
|
|
|
|
params.fieldsearch = this.getFieldsForSearch();
|
|
|
|
|
params.fieldsearch_last = this.getFieldsLastForSearch();
|
|
|
|
|
|
|
|
|
|
@@ -167,6 +167,7 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|
|
|
|
username: 1,
|
|
|
|
|
name: 1,
|
|
|
|
|
surname: 1,
|
|
|
|
|
lasttimeonline: 1,
|
|
|
|
|
'profile.img': 1,
|
|
|
|
|
"profile.mygroups": 1,
|
|
|
|
|
'profile.qualifica': 1,
|
|
|
|
|
@@ -177,12 +178,12 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
params = {...params, ...otherparams};
|
|
|
|
|
params = { ...params, ...otherparams };
|
|
|
|
|
|
|
|
|
|
return tools.executeQueryTable(this, idapp, params, user);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
|
|
|
|
MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
|
|
|
|
const MyBacheca = this;
|
|
|
|
|
|
|
|
|
|
const query = [
|
|
|
|
|
@@ -509,7 +510,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MyBachecaSchema.statics.getCompleteRecord = function(idapp, id) {
|
|
|
|
|
MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
|
|
|
|
|
const MyBacheca = this;
|
|
|
|
|
|
|
|
|
|
return MyBacheca.getMyRecById(idapp, id);
|
|
|
|
|
@@ -519,4 +520,4 @@ MyBachecaSchema.statics.getCompleteRecord = function(idapp, id) {
|
|
|
|
|
|
|
|
|
|
const MyBacheca = mongoose.model('MyBacheca', MyBachecaSchema);
|
|
|
|
|
|
|
|
|
|
module.exports = {MyBacheca};
|
|
|
|
|
module.exports = { MyBacheca };
|
|
|
|
|
|