Skip to content

Add initial implementation of QueryCollection - #62

Merged
KyleAMathews merged 12 commits into
mainfrom
querycollection
May 12, 2025
Merged

Add initial implementation of QueryCollection#62
KyleAMathews merged 12 commits into
mainfrom
querycollection

Conversation

@KyleAMathews

@KyleAMathewsKyleAMathews commented May 9, 2025

Copy link
Copy Markdown
Collaborator

Fixes#4

consttodoCollection=createQueryCollection({queryKey: [`todoItems`],queryFn: async()=>fetch(`/api/todos`),getPrimaryKey: (item)=>item.id})constuserCollection=createQueryCollection({queryKey: [`userItems`],queryFn: async()=>fetch(`/api/users`),getPrimaryKey: (item)=>item.id})const{data: completedTodos}=useLiveQuery(q=>q.from({ todoCollection }).join({from: userCollection,on: [`@todoCollection.user_id`,`=`,`@userCollection.id`]}).where(`@todoCollection.is_completed`,`=`,true))// MutationconsttoggleIsCompleted=useOptimisticMutation({ mutationFn })toggleIsCompleted.mutate(()=>todoCollection.update(todo,(draft)=>draft.is_completed=!draft.is_completed))

TODOs

  • update the example
  • can we also accept an already created query instance?

@changeset-bot

changeset-botBot commented May 9, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f967d9c

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

This PR includes changesets to release 2 packages
NameType
@tanstack/db-collectionsPatch
examples/react/todoPatch

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

@thruflothruflo mentioned this pull request May 11, 2025
@KyleAMathewsKyleAMathews added this to the v0.1.0 Release milestone May 12, 2025
@pkg-pr-new

Copy link
Copy Markdown

examples/react/todo

npm i https://pkg.pr.new/@tanstack/db-collections@62
npm i https://pkg.pr.new/@tanstack/optimistic@62
npm i https://pkg.pr.new/@tanstack/react-optimistic@62

commit: f967d9c

@KyleAMathews
KyleAMathews merged commit 382783e into mainMay 12, 2025
@KyleAMathews
KyleAMathews deleted the querycollection branch May 12, 2025 17:41
@github-actionsgithub-actionsBot mentioned this pull request May 12, 2025
cursorBot pushed a commit that referenced this pull request Jul 16, 2025
Sign up for freeto 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.

RFC: Specialized Collection Types for Data Sources

1 participant

@KyleAMathews