Ver 0.2.8
Added msg Server error in every pages Nuovo Gruppo non funziona. Corretto altre funzioni del Gruppo Errore del server" Network Error", fare pagina test con altri host per vedere se da lo stesso msg, con IP
This commit is contained in:
@@ -5,6 +5,7 @@ const tools = require('../tools/general');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = 'F';
|
||||
|
||||
@@ -14,6 +15,9 @@ mongoose.plugin(schema => {
|
||||
});
|
||||
|
||||
const MyGroupSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
@@ -105,6 +109,8 @@ MyGroupSchema.statics.getFieldsForSearch = function() {
|
||||
MyGroupSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
|
||||
const { User } = require('./user');
|
||||
|
||||
if (params.options) {
|
||||
if (tools.isBitActive(params.options, shared_consts.OPTIONS_SEARCH_USER_ONLY_FULL_WORDS)) {
|
||||
params.fieldsearch = User.getFieldsForSearchUserFriend();
|
||||
@@ -116,6 +122,27 @@ MyGroupSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
MyGroupSchema.pre('save', async function(next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await MyGroup.findOne().limit(1).sort({_id: -1});
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
else
|
||||
this._id = myrec._doc._id + 1;
|
||||
|
||||
} else {
|
||||
this._id = 1;
|
||||
}
|
||||
|
||||
this.date_created = new Date();
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
|
||||
MyGroupSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const myfind = {idapp};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user