Table MySkills
This commit is contained in:
@@ -14,15 +14,46 @@ mongoose.plugin(schema => {
|
||||
});
|
||||
|
||||
const SectorSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
idSector: {
|
||||
type: Number
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
},
|
||||
theme: {
|
||||
type: String,
|
||||
},
|
||||
main: {
|
||||
type: Boolean,
|
||||
}
|
||||
});
|
||||
|
||||
SectorSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await Sector.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;
|
||||
}
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
SectorSchema.statics.findAllIdApp = function (idapp) {
|
||||
|
||||
Reference in New Issue
Block a user