Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @POST api/clients
- // @desc Create A Clients
- router.post('/', (req, res) => {
- ClientModel.findOne({ name: req.body.name }).then(client => {
- if (client) {
- return res.status(400).json({ name: 'Client already exist' });
- } else {
- const newClient = new ClientModel({
- name: req.body.name,
- handle: req.body.name.toLowerCase(),
- pgf_fb_x: req.body.pgf_fb_x,
- });
- newClient
- .save()
- .then(client => res.json(client))
- .catch(err => console.log(err));
- // WHERE I WANT TO UPDATE
- ClientModel.findOneAndUpdate(
- { pgf_fb_xt: req.body.pgf_fb_x },
- { new: true }
- ).then(client => res.json(client));
- // END OF UPDATE
- }
- });
- });
Add Comment
Please, Sign In to add comment