added fix to allow increase no. of reference fields without reseting counter #53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows a user to increase his scope fields without resetting his counter.
For example if we have reference fields -> ["city", "district"] and for some reason, we want reference fields -> ["city", "district", "country"], currently there is no way to do it.
This increase and fix also requires modifying your existing counter collection - so a script is added for same.
How the fix works:
Step 1- Use the script incrementScopePrep.js to change the id of existing counters by adding a suitable suffix
Step 2 - Add the following fields in options :
Logic involved -
While incrementing, we check if old_reference_fields is set, if yes, then we first try to find new counter as per new reference field, if found, it is incremented, else we create a counter based on seq on older counter (which has a different id)
I implemented this, as I needed this feature urgently. Would love to know opinions about this approach and any other feedback about this PR.
Also would appreciate if eslint preferences of the project are updated so PRs can be automatically formatted as per project standard. Current autofix leads to lots of extra whitespaces as visible in the PR.