Advertisement
jamesmyers

Untitled

Mar 13th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //mongoose scehama
  2.  
  3. var mongoose = require('mongoose');
  4.  
  5. var pollsSchema = new mongoose.Schema({
  6.     question: String,
  7.     responses: [{
  8.         responseText: String,
  9.         votes: {
  10.             type: Number,
  11.             default: 0
  12.         }
  13.     }]
  14. })
  15.  
  16.  
  17. module.exports = mongoose.model('Polls', pollsSchema);
  18.  
  19. //api
  20.  
  21. /* PUT /polls/:id */
  22. router.put('/api/polls/:id', function (req, res, next) {
  23.     console.log(req.body);    
  24.     Polls.findByIdAndUpdate(req.params.id, req.body, function (err, post) {
  25.         if (err) return next(err);
  26.         res.json(post);
  27.     });
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement