Skip to content

Conversation

@KyleAMathews
Copy link
Collaborator

@KyleAMathews KyleAMathews commented Jun 19, 2025

You now must either pass an explicit type or schema - passing both will conflict.

I also removed the broken preloadCollection so I didn't have to fix its types 😆 the plan is make collections lazy by default and expose a .start() method which returns a promise that resolves when the collection finishes loading.

Fix #116 #76

@changeset-bot
Copy link

changeset-bot bot commented Jun 19, 2025

🦋 Changeset detected

Latest commit: bb19cac

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 Patch
@tanstack/db-example-react-todo Patch
@tanstack/react-db Patch
@tanstack/vue-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

@github-actions
Copy link
Contributor

github-actions bot commented Jun 19, 2025

Size Change: -130 B (-0.5%)

Total Size: 26 kB

Filename Size Change
./packages/db/dist/esm/collection.js 5.57 kB -204 B (-3.53%)
./packages/db/dist/esm/index.js 409 B -8 B (-1.92%)
./packages/db/dist/esm/query/compiled-query.js 1.39 kB +82 B (+6.29%) 🔍
ℹ️ View Unchanged
Filename Size
./packages/db/dist/esm/deferred.js 230 B
./packages/db/dist/esm/errors.js 150 B
./packages/db/dist/esm/proxy.js 3.75 kB
./packages/db/dist/esm/query/evaluators.js 1.06 kB
./packages/db/dist/esm/query/extractors.js 870 B
./packages/db/dist/esm/query/functions.js 1.28 kB
./packages/db/dist/esm/query/group-by.js 976 B
./packages/db/dist/esm/query/joins.js 1.14 kB
./packages/db/dist/esm/query/order-by.js 1.42 kB
./packages/db/dist/esm/query/pipeline-compiler.js 878 B
./packages/db/dist/esm/query/query-builder.js 2.14 kB
./packages/db/dist/esm/query/select.js 1.1 kB
./packages/db/dist/esm/query/utils.js 1.13 kB
./packages/db/dist/esm/SortedMap.js 997 B
./packages/db/dist/esm/transactions.js 1.31 kB
./packages/db/dist/esm/utils.js 219 B

compressed-size-action::db-package-size

@github-actions
Copy link
Contributor

github-actions bot commented Jun 19, 2025

Size Change: 0 B

Total Size: 822 B

ℹ️ View Unchanged
Filename Size
./packages/react-db/dist/esm/index.js 173 B
./packages/react-db/dist/esm/useLiveQuery.js 409 B
./packages/react-db/dist/esm/useOptimisticMutation.js 240 B

compressed-size-action::react-db-package-size

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 19, 2025

@tanstack/db-example-react-todo

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

commit: bb19cac

@KyleAMathews KyleAMathews requested a review from samwillis June 19, 2025 20:29
@KyleAMathews KyleAMathews moved this to In Progress in 0.1.0 release Jun 19, 2025
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.

All looks great!

Aside, with the work on #185 the new useLiveQuery will probably want to optionally take a schema too so that a user can validate writes to a derived collection. I have the groundworks for this.

value: valueWithKey,
type: `update`,
})
// Only delete is left as an option
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the logic here is correct.

It may be good to add an else that throws with a "this should never happen" error. Currently, if the logic is wrong, the error is silently eaten but we want to know about it.

I quite like the pattern I have seen others using where they have a shouldNeverHappen() function that in dev mode triggers a breakpoint with debugger, and in prod throws an error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea — I'll add this

* This type is used internally to resolve the collection item type based on the provided generics and schema.
* Users should not need to use this type directly, but understanding the priority order helps when defining collections.
*/
export type ResolveType<
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks good!

@KyleAMathews KyleAMathews merged commit f6abe9b into main Jun 23, 2025
4 checks passed
@KyleAMathews KyleAMathews deleted the schema-only branch June 23, 2025 13:40
@github-project-automation github-project-automation bot moved this from In Progress to Done in 0.1.0 release Jun 23, 2025
@github-actions github-actions bot mentioned this pull request Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Use schema type if types aren't directly passed in

3 participants