Webpage Editor functionality

This commit is contained in:
paoloar77
2022-11-10 19:33:23 +01:00
parent 32dcc1702d
commit c7ca4e2878
15 changed files with 227 additions and 5 deletions

View File

@@ -111,7 +111,6 @@ const CircuitSchema = new Schema({
},
deperimento: {
type: Boolean,
default: true,
},
freq_deper: { // H, D, W, M, Y
type: String,
@@ -735,6 +734,13 @@ CircuitSchema.statics.updateData = async function(idapp, circuitname) {
};
CircuitSchema.statics.setDeperimentoOff = async function() {
return await Circuit.updateMany({}, {$set: {'deperimento': false}},
{new: false});
};
const Circuit = mongoose.model('Circuit', CircuitSchema);
module.exports = {Circuit};

View File

@@ -2,6 +2,7 @@ const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const tools = require('../tools/general');
const {ObjectID} = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";
@@ -13,9 +14,18 @@ mongoose.plugin(schema => {
});
const MyElemSchema = new Schema({
_id: {
type: ObjectID,
default: function() {
return new ObjectID();
},
},
idapp: {
type: String,
},
path: {
type: String,
},
type: {
type: Number,
},
@@ -98,6 +108,14 @@ const MyElemSchema = new Schema({
],
});
MyElemSchema.pre('save', async function(next) {
if (this.isNew) {
this._id = new ObjectID();
}
next();
});
MyElemSchema.statics.getFieldsForSearch = function () {
return [{ field: 'title', type: tools.FieldType.string },
{ field: 'content', type: tools.FieldType.string }]