From c2d4e1255bee5116136fad33ab8684ecfbec11b9 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 3 Nov 2016 11:33:32 -0600 Subject: [PATCH] terseness --- models/setting.js | 10 ++++++++-- routes/api/settings/index.js | 12 ++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/models/setting.js b/models/setting.js index aec51c810..2a82d5e94 100644 --- a/models/setting.js +++ b/models/setting.js @@ -1,11 +1,17 @@ const mongoose = require('../mongoose'); -const uuid = require('uuid'); const Schema = mongoose.Schema; const SettingSchema = new Schema({ + id: {type: String, default: '1'}, moderation: {type: String, enum: ['pre', 'post'], default: 'pre'}, -}, {timestamps: {createdAt: 'created_at', updatedAt: 'updated_at'}}); +}, { + _id: false, + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at' + } +}); SettingSchema.statics.getSettings = function () { return this.findOne(); diff --git a/routes/api/settings/index.js b/routes/api/settings/index.js index b801fb8ea..36037a184 100644 --- a/routes/api/settings/index.js +++ b/routes/api/settings/index.js @@ -4,19 +4,11 @@ const path = require('path'); const Setting = require(path.resolve(__dirname, 'models/setting')); router.get('/settings', (req, res, next) => { - Setting.getSettings().then(settings => { - res.json(settings); - }).catch(error => { - next(error); - }); + Setting.getSettings().then(res.json).catch(next); }); router.put('/settings', (req, res, next) => { - Setting.updateSettings(req.body).then(updatedSettings => { - res.json(updatedSettings); - }).catch(error => { - next(error); - }); + Setting.updateSettings(req.body).then(res.json).catch(next); }); module.exports = router;