feat: add orderBy option to BulkSaveOptions#735
Draft
ascott18 wants to merge 4 commits into
Draft
Conversation
Add an orderBy comparator to BulkSaveOptions that allows customization of the order in which items are sent to the server during a bulk save. The server respects client ordering when possible, but may reorder items to satisfy foreign key dependencies. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a client-side ordering hook for bulk saves in coalesce-vue by introducing an orderBy comparator on BulkSaveOptions. This enables callers to control item ordering in the request payload (with the server still free to reorder when required for FK dependencies), improving support for workflows that require deterministic operation order.
Changes:
- Added
BulkSaveOptions.orderByand applied it in$bulkSavePreviewwhile keepingitemsandrawItemsaligned. - Added Vitest coverage for ordering behavior in both
$bulkSaverequest payloads and$bulkSavePreview. - Updated bulk save documentation and added a changelog entry describing the new option and FK-aware server behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coalesce-vue/src/viewmodel.ts | Adds orderBy to BulkSaveOptions and applies it to bulk save preview/payload construction. |
| src/coalesce-vue/test/viewmodel.spec.ts | Adds tests validating ordering behavior for $bulkSave and $bulkSavePreview. |
| docs/stacks/vue/layers/viewmodels.md | Documents the new orderBy option and clarifies server-side FK dependency reordering. |
| CHANGELOG.md | Records the new orderBy feature in the release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Bulk saves currently send items in breadth-first traversal order with no way to customize it. This means scenarios that require a specific operation order -- like promoting one user before demoting another to avoid permission errors -- cannot use bulk saves and must fall back to sequential individual saves.
This adds an
orderBycomparator toBulkSaveOptionsthat controls the order items appear in the payload sent to the server. The server's existing save loop already naturally preserves client ordering for items at the same FK dependency level, only reordering when necessary to resolve foreign key references. So no server-side changes are needed.Changes
BulkSaveOptions.orderBy: New comparator function receivingBulkSaveRequestRawItempairs (which expose.model,.action,.metadata, etc.). Works likeArray.prototype.sort.$bulkSavePreview: Applies the sort after items are collected, keeping therawItemsanditemsarrays in sync.$bulkSavepayloads and$bulkSavePreviewresults.orderByoption and the server's FK-aware reordering behavior.