diff --git a/models/User.js b/models/User.js index c309cf6..73ba437 100644 --- a/models/User.js +++ b/models/User.js @@ -84,6 +84,11 @@ const UserSchema = mongoose.Schema({ required: false, default: 0, }, + note: { + type: String, + required: false, + default: "", + } }, food: [ { diff --git a/routes/userInfo.js b/routes/userInfo.js index 2788d97..9c9280a 100644 --- a/routes/userInfo.js +++ b/routes/userInfo.js @@ -68,6 +68,24 @@ router.post('/:id/fitness/currentDay', verify, async (req, res) => { } }) +router.get('/:id/fitness/note', verify, async (req, res) => { + const user = await User.findOne({ _id: req.params.id }) + + res.send({note: user.fitness.note}) +}) + +router.post('/:id/fitness/note', verify, async (req, res) => { + const user = await User.findOne({ _id: req.params.id }) + + try { + user.fitness.note = req.body.note + user.save() + res.send({ sent: true }) + } catch (err) { + res.status(400).send(err) + } +}) + router.post('/:id/addFood', verify, async (req, res) => { const food = { name: req.body.name,