var Account = require('../../app/models/account');

exports.update = function (req, res) {
    Account.findById(req.params.id, function (err, account) {
        if (!account)
            return next(new Error('Could not load Document'));
        else {
            if (req.body.foreName) {
                account.foreName = req.body.foreName
            }
            if (req.body.sureName) {
                account.sureName = req.body.sureName
            }
            if (req.body.phoneNumber) {
                account.phoneNumber = req.body.phoneNumber
            }

            account.save(function (err) {
                if (err)
                    res.json({ message: 'Error' });
                else
                    res.json({ message: 'Account Updated' });
            });
        }
    });
}
var Account = require('../../app/models/account');

exports.update = function (req, res) {
    Account.findById(req.params.id, function (err, account) {
        if (!account)
            return next(new Error('Could not load Document'));
        else {
            if (req.body.foreName) {
                account.foreName = req.body.foreName
            }
            if (req.body.sureName) {
                account.sureName = req.body.sureName
            }
            if (req.body.phoneNumber) {
                account.phoneNumber = req.body.phoneNumber
            }

            account.save(function (err) {
                if (err)
                    res.json({ message: 'Error' });
                else
                    res.json(account);
            });
        }
    });
}
Update now returns the account info
Update now returns the account info
