Skip to content

Commit

Permalink
manually set record version attribute during epilogue update
Browse files Browse the repository at this point in the history
  • Loading branch information
Wsiegenthaler committed Mar 20, 2018
1 parent 97d7e08 commit ba4ab36
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/epilogue.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,18 @@ function EpilogueExport(embed, sequelize, epilogue) {

/* Perform updates and skip the default write milestone */
resource.update.write.before((req, res, ctx) => {
ctx.instance.set(req.body);
if (options.prefetchUpdate) {
ctx.instance.set(req.body);

/* Ensure version attribute is set */
var ver = resource.model.options.version;
if (ver) {
ver = lo.isString(ver) ? ver : 'version';
ctx.instance.set(ver, req.body[ver], { raw: true });
ctx.instance.changed(ver, true); // force update
}
} else ctx.instance = req.body;

return update(resource.model, ctx.instance, include, options)
.then(inst => ctx.instance = inst)
.catch(handleError)
Expand Down

0 comments on commit ba4ab36

Please sign in to comment.