Add a typescript query builder for views #3812
Draft
+1,096
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
This adds a way to build queries within typescript Views.
I'm still waiting for #3685 to go in before I update the bindings to return queries.
For examples and syntax, you can look at the tests in crates/bindings-typescript/tests/query.test.ts.
This still needs some cleanup, and a few places need to have the types tightened:
ViewFns allow any query, but we need to restrict the type to match the view return type.I can also add back functions for things like inequality once we are ok with the rest of it.
API and ABI breaking changes
This adds some new API surface, but does not break existing code.
Expected complexity level and risk
Testing
There are some tests for the sql that gets emitted.
I'll probably rely on manual testing of the typescript views for now.