Webpage Editor functionality
This commit is contained in:
@@ -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 }]
|
||||
|
||||
Reference in New Issue
Block a user