- Requirements
- Send Msg to Passeggeri
This commit is contained in:
Paolo Arena
2020-03-10 21:44:14 +01:00
parent 26715cda44
commit fbc85ce06a
37 changed files with 2392 additions and 673 deletions

View File

@@ -95,7 +95,37 @@ SettingsSchema.statics.findAllIdApp = function (idapp, serv) {
});
};
SettingsSchema.statics.setKeyNum = async function (idapp, key, value) {
const Settings = this;
const Settings = mongoose.model('Settings', SettingsSchema);
let myrec = await Settings.findOne({ idapp, key });
if (!myrec) {
myrec = new Settings({ key });
myrec._id = new ObjectID();
myrec.idapp = idapp;
myrec.type = tools.FieldType.number;
myrec.value_num = value;
return await myrec.save();
} else {
myrec = await Settings.findOneAndUpdate({ idapp, key }, { $set: { value_num: value } }, { new: false});
}
};
SettingsSchema.statics.getKeyNum = async function (idapp, key, mydefault) {
const Settings = this;
const ret = await Settings.findOne({ idapp, key});
if (!!ret) {
return ret.value_num;
} else {
return mydefault;
}
};
const Settings = mongoose.model('Settings', SettingsSchema);
module.exports = { Settings };