Skip to content

allow calling create, update, delete with a disabled unitOfWork#140

Merged
jdeniau merged 4 commits intomainfrom
deactivate-unit-of-work-on-update
Mar 6, 2024
Merged

allow calling create, update, delete with a disabled unitOfWork#140
jdeniau merged 4 commits intomainfrom
deactivate-unit-of-work-on-update

Conversation

@jdeniau
Copy link
Copy Markdown
Member

@jdeniau jdeniau commented Mar 5, 2024

Fixes #94

Copying from here:

We might want to deactivate the unitOfWork when we don't care about the result of the create, update or delete method.

Imagine a call that does fetch a item:

const item = await repository.find(1, { fields: '@id,name,type' });

later, we do have a modal that allow to change the name, but we don't care about the return

await repository.update(item.set('name', 'new name'), { fields: '@id' });

The unitOfWork will register the data with only the @id.

If later call a "type changer":

await repository.update(item.set('type', 'new type'), { fields: '@id' });

The getDirtyData will return that only the @id is known, and then send a call with:

{
  name: 'new name',
  type: 'new type',
}

We might want to disable the unit of work when "updating", as we do disable it for find method (a put is "just" a get that change some data before).

@jdeniau jdeniau requested review from a team and badaz March 5, 2024 18:44
Copy link
Copy Markdown
Contributor

@badaz badaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand why we would prevent creating, updating, deleting with a disabled unitOfWork in the first place? So I'm quite ok with this

@jdeniau jdeniau merged commit 26910bd into main Mar 6, 2024
@jdeniau jdeniau deleted the deactivate-unit-of-work-on-update branch March 6, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should we allow deactivating unitOfWork on create, update or delete method

3 participants