- Fixed 'Ask Info' and 'Book' if the email arrived... - Added "Settings" table: URL_FACEBOOK, TELEGRAM_SUPPORT, URL_INSTAGRAM, WHATSAPP_CELL, INT_CODE, MAIN_EMAIL, CONTACTS_EMAIL_CELL, CALL_WORKING_DAYS, EVENTS_CAL, MSG_REPLY_AFTER_BOOKING. -
73 lines
1.4 KiB
JavaScript
73 lines
1.4 KiB
JavaScript
const mongoose = require('mongoose');
|
|
const Schema = mongoose.Schema;
|
|
|
|
const tools = require('../tools/general');
|
|
|
|
mongoose.Promise = global.Promise;
|
|
mongoose.level = "F";
|
|
|
|
|
|
// Resolving error Unknown modifier: $pushAll
|
|
mongoose.plugin(schema => {
|
|
schema.options.usePushEach = true
|
|
});
|
|
|
|
const SettingsSchema = new Schema({
|
|
idapp: {
|
|
type: String,
|
|
},
|
|
key: {
|
|
type: String,
|
|
},
|
|
type: {
|
|
type: Number,
|
|
},
|
|
value_str: {
|
|
type: String,
|
|
},
|
|
value_date: {
|
|
type: Date,
|
|
},
|
|
value_num: {
|
|
type: Number,
|
|
}
|
|
});
|
|
|
|
SettingsSchema.statics.executeQueryTable = function (idapp, params) {
|
|
return tools.executeQueryTable(this, idapp, params);
|
|
};
|
|
|
|
SettingsSchema.statics.getValDbSettings = function (idapp, key) {
|
|
return Settings.findOne({ idapp, key })
|
|
.then((myrec) => {
|
|
if (myrec) {
|
|
if (myrec.type === this.FieldType.date)
|
|
return myrec.value_date;
|
|
if (myrec.type === this.FieldType.number)
|
|
return myrec.value_num;
|
|
else
|
|
return myrec.value_str;
|
|
} else {
|
|
return ''
|
|
}
|
|
|
|
}).catch((err) => {
|
|
return null;
|
|
});
|
|
|
|
};
|
|
|
|
SettingsSchema.statics.findAllIdApp = function (idapp) {
|
|
const Settings = this;
|
|
|
|
const myfind = { idapp };
|
|
|
|
return Settings.find(myfind, (err, arrrec) => {
|
|
return arrrec
|
|
});
|
|
};
|
|
|
|
const Settings = mongoose.model('Settings', SettingsSchema);
|
|
|
|
module.exports = { Settings };
|