Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var query = {
- where: {
- id: req.params.id
- },
- include: defaultIncludes()
- }
- models.products.findOne(query)
- .then(function (product) {
- if (!product) {
- return res.status(404).json({message: 'Product not found' });
- } else {
- this.product = product;
- return models.services.findById(req.body.service_id);
- }
- })
- .then(function (service) {
- return this.product.addServices(service);
- })
- .then(function (result) {
- return this.product.save();
- // return models.products.findOne(query);
- })
- .then(function (product) {
- return res.status(200).json(product)
- })
- .catch(function (err) {
- logger.error(err);
- return res.status(500).json({error: err.message});
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement