Skip to content

Collections must have a getId function & use an id for update/delete operators - #134

Merged
KyleAMathews merged 12 commits into
mainfrom
kylemathews-ids-for-ref
Jun 5, 2025
Merged

KyleAMathews merged 12 commits into
mainfrom
kylemathews-ids-for-ref

Conversation

@KyleAMathews

@KyleAMathews KyleAMathews commented Jun 3, 2025 •

Copy link
Copy Markdown
Collaborator

fixes #54

Enforce globally unique ids for each item by making the internal key be a combination of the collection id & item id.

Then just reference objects for delete/update by the object id.

Todo

  • throw error if you try to update an id
  • throw error if you try to insert new object w/ same id (from collection or sync interface)
  • update example
  • add changeset

@changeset-bot

changeset-bot Bot commented Jun 3, 2025 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5be8ab5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@tanstack/db-collections Patch
@tanstack/db-example-react-todo Patch
@tanstack/react-db Patch
@tanstack/vue-db Patch
@tanstack/db Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 3, 2025 •

Copy link
Copy Markdown

@tanstack/db-example-react-todo

npm i https://pkg.pr.new/@tanstack/db@134
npm i https://pkg.pr.new/@tanstack/db-collections@134
npm i https://pkg.pr.new/@tanstack/react-db@134
npm i https://pkg.pr.new/@tanstack/vue-db@134

commit: 5be8ab5

@KyleAMathews
KyleAMathews requested a review from samwillis June 3, 2025 21:10
@KyleAMathews KyleAMathews changed the title Collections must have ids & use an id for update/delete operators Collections must have a getId function & use an id for update/delete operators Jun 3, 2025
@KyleAMathews
KyleAMathews force-pushed the kylemathews-ids-for-ref branch from 785274c to 1e77b68 Compare June 5, 2025 15:01

@samwillis samwillis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍

@KyleAMathews
KyleAMathews merged commit 1fbb844 into main Jun 5, 2025
@KyleAMathews
KyleAMathews deleted the kylemathews-ids-for-ref branch June 5, 2025 17:40
@github-actions github-actions Bot mentioned this pull request Jun 5, 2025
cursor Bot pushed a commit that referenced this pull request Jul 16, 2025
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.

For update/delete operators, reference items in the collection by their id (instead of an object ref)

2 participants