Skip to content

Conversation

daveycodez
Copy link
Contributor

This PR addresses the majority of "any" type usage in the rxdb-db-collection adapter as well as fixes for only querying documents where _deleted is false, which fixes issues when using localStorage or other persistent storage mechanisms.

Fixes #630

Replaces generic 'any' types with more specific types such as 'Subscription' and 'Record<string, unknown>' for improved type safety. Removes unnecessary type assertions and updates function signatures and variable declarations accordingly.
Added '_deleted': false to query selectors to ensure only non-deleted documents are included during synchronization. This improves data consistency by excluding soft-deleted records from sync operations.
Copy link

changeset-bot bot commented Oct 10, 2025

🦋 Changeset detected

Latest commit: ee9eca8

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

This PR includes changesets to release 1 package
Name Type
@tanstack/rxdb-db-collection 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

Updated the stripRxdbFields function to use a stricter type for the input parameter and removed unnecessary handling for arrays and nullish values.
Copy link
Collaborator

@samwillis samwillis left a comment

Choose a reason for hiding this comment

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

Thanks for this @daveycodez

Would it be possible to add a test that validates the delete behaviour?

@daveycodez
Copy link
Contributor Author

daveycodez commented Oct 10, 2025

Thanks for this @daveycodez

Would it be possible to add a test that validates the delete behaviour?

Seems like a complex test that would need to run in the web browser and then refresh the page to verify. It requires access to localStorage.

The issue was that it loads the data and skips rxdb query and runs directly on the storage instance which skips rxdb filtering out deleted documents.

Added 'rxjs' with version >=7.8.2 to peerDependencies in package.json to ensure compatibility and proper dependency management.
Copy link

pkg-pr-new bot commented Oct 11, 2025

More templates

@tanstack/angular-db

npm i https://pkg.pr.new/@tanstack/angular-db@667

@tanstack/db

npm i https://pkg.pr.new/@tanstack/db@667

@tanstack/db-ivm

npm i https://pkg.pr.new/@tanstack/db-ivm@667

@tanstack/electric-db-collection

npm i https://pkg.pr.new/@tanstack/electric-db-collection@667

@tanstack/query-db-collection

npm i https://pkg.pr.new/@tanstack/query-db-collection@667

@tanstack/react-db

npm i https://pkg.pr.new/@tanstack/react-db@667

@tanstack/rxdb-db-collection

npm i https://pkg.pr.new/@tanstack/rxdb-db-collection@667

@tanstack/solid-db

npm i https://pkg.pr.new/@tanstack/solid-db@667

@tanstack/svelte-db

npm i https://pkg.pr.new/@tanstack/svelte-db@667

@tanstack/trailbase-db-collection

npm i https://pkg.pr.new/@tanstack/trailbase-db-collection@667

@tanstack/vue-db

npm i https://pkg.pr.new/@tanstack/vue-db@667

commit: ee9eca8

Copy link
Collaborator

@samwillis samwillis left a comment

Choose a reason for hiding this comment

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

Thanks @daveycodez for this. I've added a changeset and will merge. Will be in the next release.

@samwillis samwillis merged commit d523759 into TanStack:main Oct 14, 2025
6 checks passed
@github-actions github-actions bot mentioned this pull request Oct 14, 2025
Copy link
Contributor

🎉 This PR has been released!

Thank you for your contribution!

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.

Deleting RxDB rows does not persist to localStorage

2 participants