loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Transactions on Rectify

Open kobaska opened this issue 9 years ago • 5 comments

Bug or feature request

  • [ ] Bug
  • [x] Feature request

Description of feature

Pass transaction through to rectifyOnSave and rectifyOnDelete functions which get called on the after save and after delete hooks.

kobaska avatar Dec 14 '16 05:12 kobaska

I see two options we could do:

  1. Pass options object through to all the calls related to rectify which means we have to add options to PersistedModel.rectifyChange, Change.rectifyAllChanges and Change.rectifyModelChanges:

PersistedModel.rectifyChange = function(id, options, callback) { ..... };

Change.rectifyModelChanges = function(modelName, modelIds, options, callback) { }

  1. Disable rectify when transaction exist, let the client handle rectify (Which is not great)

From : Model.observe('after save', rectifyOnSave);

To:

Model.observe('after save', function(ctx, next) {
 if (ctx.options.transaction) {
   next();
 } else {
   rectifyOnSave(ctx, next);
 }
});

kobaska avatar Dec 15 '16 22:12 kobaska

Hey @bajtos, Can you please give your view on this, whether transaction is something you have thought about in replication scenarios?

kobaska avatar Dec 21 '16 22:12 kobaska

Hi @kobaska, your first proposal makes a lot of sense to me, we should add options argument to rectify* methods. This will also enable context-propagation as proposed/implemented by #3023 (see also #1495).

Would you mind contributing this improvement yourself?

bajtos avatar Dec 22 '16 15:12 bajtos

Greetings. I am a college of @kobaska. Am starting work on adding options to rectify methods this week.

ericmorentin avatar Jan 23 '17 01:01 ericmorentin

@ericmorentin Great, I'm looking forward to your contribution(s)!

bajtos avatar Jan 23 '17 10:01 bajtos