Skip to content

feat: add orderBy option to BulkSaveOptions#735

Draft
ascott18 wants to merge 4 commits into
mainfrom
ascott18-bulk-save-ordering-options
Draft

feat: add orderBy option to BulkSaveOptions#735
ascott18 wants to merge 4 commits into
mainfrom
ascott18-bulk-save-ordering-options

Conversation

@ascott18

Copy link
Copy Markdown
Collaborator

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 orderBy comparator to BulkSaveOptions that 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 receiving BulkSaveRequestRawItem pairs (which expose .model, .action, .metadata, etc.). Works like Array.prototype.sort.
  • $bulkSavePreview: Applies the sort after items are collected, keeping the rawItems and items arrays in sync.
  • Tests: Two new tests verifying ordering in both $bulkSave payloads and $bulkSavePreview results.
  • Docs: Updated bulk save section noting the orderBy option and the server's FK-aware reordering behavior.
  • Changelog: Added feature entry.

ascott18 and others added 3 commits June 24, 2026 15:22
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.orderBy and applied it in $bulkSavePreview while keeping items and rawItems aligned.
  • Added Vitest coverage for ordering behavior in both $bulkSave request 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.

Comment thread src/coalesce-vue/test/viewmodel.spec.ts
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

2 participants