Skip to content

Conversation

@MLewiDev
Copy link

@MLewiDev MLewiDev commented May 4, 2022

Added .save function to stores.
It uses logic from single model and applies it to the whole store.
Tests added based on the model tests.

@MLewiDev MLewiDev requested review from abzainuddin and daanvdk May 4, 2022 12:36
@daanvdk
Copy link
Contributor

daanvdk commented May 4, 2022

So one thing that we should look into if we want to add it:

This currently does not handle saving deletions from the top level store, this is supported on the binder API level in the multiput (next to data you can also send deletions with a list of ids that have to be deleted.).

However this means we should start to keep track on the store which ids have been removed from it. (Or which ids it originally had and on save just check which ones are not in there anymore)

@codecov-commenter
Copy link

Codecov Report

Merging #134 (eeb7cab) into master (cec7709) will increase coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #134      +/-   ##
==========================================
+ Coverage   93.63%   93.75%   +0.12%     
==========================================
  Files           5        5              
  Lines         848      865      +17     
  Branches      201      204       +3     
==========================================
+ Hits          794      811      +17     
  Misses         44       44              
  Partials       10       10              
Impacted Files Coverage Δ
src/Model.js 91.01% <100.00%> (+0.04%) ⬆️
src/Store.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cec7709...eeb7cab. Read the comment docs.

Comment on lines +526 to +530
const promises = [];
for (const model of this.models) {
promises.push(model._afterSaveAll(res, options));
}
return Promise.all(promises);
Copy link

Choose a reason for hiding this comment

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

It should also call this.clearSetChanges after successful save, otherwise this.hasUserChanges will always stay true even after saving the store. I encountered this issue in a project that already uses changes from this PR

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.

5 participants