Lista Doni Navi
This commit is contained in:
9
src/server/models/settings.js
Normal file → Executable file
9
src/server/models/settings.js
Normal file → Executable file
@@ -43,7 +43,8 @@ const SettingsSchema = new Schema({
|
||||
});
|
||||
|
||||
SettingsSchema.statics.getFieldsForSearch = function () {
|
||||
return ['key', 'value_str']
|
||||
return [{ field: 'key', type: tools.FieldType.string },
|
||||
{ field: 'value_str', type: tools.FieldType.string }, { field: 'value_num', type: tools.FieldType.number }]
|
||||
};
|
||||
|
||||
SettingsSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
@@ -108,7 +109,7 @@ SettingsSchema.statics.setKeyNum = async function (idapp, key, value) {
|
||||
|
||||
return await myrec.save();
|
||||
} else {
|
||||
myrec = await Settings.findOneAndUpdate({ idapp, key }, { $set: { value_num: value } }, { new: false});
|
||||
myrec = await Settings.findOneAndUpdate({ idapp, key }, { $set: { value_num: value } }, { new: false });
|
||||
}
|
||||
|
||||
};
|
||||
@@ -117,7 +118,7 @@ SettingsSchema.statics.setKeyNum = async function (idapp, key, value) {
|
||||
SettingsSchema.statics.getKeyNum = async function (idapp, key, mydefault) {
|
||||
const Settings = this;
|
||||
|
||||
const ret = await Settings.findOne({ idapp, key});
|
||||
const ret = await Settings.findOne({ idapp, key });
|
||||
if (!!ret) {
|
||||
return ret.value_num;
|
||||
} else {
|
||||
@@ -126,6 +127,6 @@ SettingsSchema.statics.getKeyNum = async function (idapp, key, mydefault) {
|
||||
|
||||
};
|
||||
|
||||
const Settings = mongoose.model('Settings', SettingsSchema);
|
||||
const Settings = mongoose.model('Settings', SettingsSchema);
|
||||
|
||||
module.exports = { Settings };
|
||||
|
||||
Reference in New Issue
Block a user