- Nave
- Requirements - Send Msg to Passeggeri
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user