fixed: se aggiungo una Provincia sul frontend non si aggiungeva
This commit is contained in:
@@ -35,11 +35,32 @@ const ProvinceSchema = new Schema({
|
||||
link_grp: {
|
||||
type: String,
|
||||
},
|
||||
card : {
|
||||
type: String,
|
||||
},
|
||||
|
||||
link_telegram: {
|
||||
type: String,
|
||||
},
|
||||
}, { _id : false });
|
||||
|
||||
ProvinceSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await Province.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();
|
||||
});
|
||||
|
||||
ProvinceSchema.statics.getRegionByStrProvince = async function(strprovince) {
|
||||
const myrec = await Province.findOne({prov: strprovince}).lean();
|
||||
if (myrec) {
|
||||
|
||||
Reference in New Issue
Block a user