NodeJS Sequelize: Issue with setting value of associations
<p>I have a many-to-many relationship between two tables, product and service, connected by a join table with a column of cost, product_service. When I create try to add a service to a product the first call does not return the updated value, even though the database has been updated, I know because I check it, I only get to see the updated value on my application when I make another call.</p>

<pre><code> 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});
  });
</code></pre>

<p>I think it might have something to do with promises, either for addServices or the save function, but I can't seem to figure it out.</p>