daily pastebin goal
31%
SHARE
TWEET

Untitled

a guest Jul 12th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // @POST api/clients
  2. // @desc Create A Clients
  3.  
  4. router.post('/', (req, res) => {
  5.   ClientModel.findOne({ name: req.body.name }).then(client => {
  6.     if (client) {
  7.      return res.status(400).json({ name: 'Client already exist' });
  8.     } else {
  9.       const newClient = new ClientModel({
  10.         name: req.body.name,
  11.         handle: req.body.name.toLowerCase(),
  12.         pgf_fb_x: req.body.pgf_fb_x,
  13.   });
  14.  
  15.   newClient
  16.     .save()
  17.     .then(client => res.json(client))
  18.     .catch(err => console.log(err));
  19.  
  20. // WHERE I WANT TO UPDATE
  21.  
  22.   ClientModel.findOneAndUpdate(
  23.     { pgf_fb_xt: req.body.pgf_fb_x },
  24.     { new: true }
  25.   ).then(client => res.json(client));
  26.  
  27. // END OF UPDATE
  28.   }
  29.  });
  30. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top