-
Notifications
You must be signed in to change notification settings - Fork 45
feat: new query syntax #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Size Change: +669 B (+2.31%) Total Size: 29.7 kB
ℹ️ View Unchanged
|
Size Change: 0 B Total Size: 561 B ℹ️ View Unchanged
|
@tanstack/db-example-react-todo
commit: |
The one failing test in this at the moment is fixed by these d2mini PRs: |
Installed this in the expo starter which has this for the query: There's no loader so the initial render has 0 items but it never re-renders after that. I called |
An optimistic/sync mutation does get it to re-render |
I tried doing a select callback and got this js error for q.from({ todoCollection }).select(({ todoCollection }) => {
return {
foo: `${todoCollection.id}`,
id: todoCollection.id,
text: todoCollection.text,
completed: todoCollection.completed,
created_at: todoCollection.created_at,
updated_at: todoCollection.updated_at,
};
}),
|
I'm not sure I love the operators being individual exports (e.g. |
Ohhhh that's because this isn't supported yet... just the operator selects... hmm that's going to confuse people |
|
I've changed my mind about putting operators under |
I wrote this code: Oh actually the test is misleading I guess? Removing the array made it work i.e. |
It's planned, as I noted above and on Discord, it will come in another PR asap. We need to decide how to name them - they have to be distinct from the main method as they now take callbacks too. |
There was a discussion about this over on the issue here: #170 (comment) Happy to change this, we didn't really reach a conclusion. They could be an import, or provided for destructuring on the useLiveQuery callback. |
I thought I had it as |
Yes this is the correct syntax |
Is that with a shape that is now lazy? I think thats behaving as it should as there are no rows yet? |
Explicit named types is the trick I think?
No the collection loads data just fine — the query just doesn't seem to detect the initial sync. Subsequent syncs & any optimistic changes do trigger a render. |
@KyleAMathews on I'm open to renaming it, but not that it operates on both arrays and strings, so you can do Obv we can't call it We could also split into two functions |
I had a similar problem a while ago, this might be helpful https://dev.to/dawidcodes/simplifying-complex-type-display-in-typescript-and-vs-code-4f1 |
Ah ok, maybe |
Implements the new query syntax from #170
todo:
features:
from
collectionfrom
subquerywhere
join
collectionjoin
subquerygroupBy
having
orderBy
(with limit+offset)useLiveQuery
useLiveQuery
The main entry point is a new
createLiveQueryCollection
function:this wraps a new
liveQueryCollectionOptions
andcreateCollection
call - the former of which can be used like the otherxxxCollectionOptions
function we have:createLiveQueryCollection
can be called with either a query builder function, or a config object that takes thequery
param as a query builder function.