mirror of
https://github.com/wassname/talk.git
synced 2026-08-05 13:30:26 +08:00
initialize settings in an init file before app accepts requests
This commit is contained in:
@@ -11,6 +11,14 @@ const SettingSchema = new Schema({
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* this is run once when the app starts to ensure settings are populated
|
||||
* @return {Promise} null initialize the global settings object
|
||||
*/
|
||||
SettingSchema.statics.init = function (defaults) {
|
||||
return this.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true});
|
||||
};
|
||||
|
||||
/**
|
||||
* gets the entire settings record and sends it back
|
||||
* @return {Promise} settings the whole settings record
|
||||
|
||||
Reference in New Issue
Block a user