Skip to content
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

feat(zero): namespace custom mutators to the table they impact #3648

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

tantaman
Copy link
Contributor

Rather than having all mutators at the top level, they'll need to be namespaced.

Example:

const mutators = {
    issue: {
      setTitle: (tx, id: string, title: string) => {
        tx.mutate.issue.update({id, title});
      },
    },
   notATableName: { doThing: () => {} }
};

The namespace is not required to match a table name but tables names are provided to intellisense at this callsite.

CleanShot 2025-01-29 at 14 15 05

Copy link

vercel bot commented Jan 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
replicache-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 29, 2025 7:58pm
zbugs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 29, 2025 7:58pm

Copy link

github-actions bot commented Jan 29, 2025

🐰 Bencher Report

Branchmlaw/namespace-mutators
Testbedlocalhost
Click to view all benchmark results
BenchmarkFile SizeBenchmark Result
kilobytes (KB)
(Result Δ%)
Upper Boundary
kilobytes (KB)
(Limit %)
zero-package.tgz📈 view plot
🚷 view threshold
919.04
(+0.02%)
937.21
(98.06%)
zero.js📈 view plot
🚷 view threshold
171.55
(0.00%)
174.99
(98.04%)
zero.js.br📈 view plot
🚷 view threshold
47.80
(0.00%)
48.76
(98.04%)
🐰 View full continuous benchmarking report in Bencher

Copy link

github-actions bot commented Jan 29, 2025

🐰 Bencher Report

Branchmlaw/namespace-mutators
Testbedlocalhost
Click to view all benchmark results
BenchmarkThroughputBenchmark Result
operations / second (ops/s)
(Result Δ%)
Lower Boundary
operations / second (ops/s)
(Limit %)
src/client/zero.bench.ts > basics > All 1000 rows x 10 columns (numbers)📈 view plot
🚷 view threshold
70.15
(-2.97%)
69.58
(99.19%)
src/client/zero.bench.ts > with filter > Lower rows 500 x 10 columns (numbers)📈 view plot
🚷 view threshold
91.98
(-2.71%)
91.09
(99.03%)
🐰 View full continuous benchmarking report in Bencher

@tantaman tantaman enabled auto-merge (rebase) January 29, 2025 19:58
@tantaman tantaman merged commit 7220949 into main Jan 29, 2025
11 checks passed
@tantaman tantaman deleted the mlaw/namespace-mutators branch January 29, 2025 20:04
@aboodman
Copy link
Contributor

aboodman commented Jan 29, 2025 via email

@aboodman
Copy link
Contributor

aboodman commented Jan 29, 2025 via email

@tantaman
Copy link
Contributor Author

(because people might misunderstand that they can only use those names)

good point.

@aboodman
Copy link
Contributor

aboodman commented Jan 29, 2025 via email

@tantaman
Copy link
Contributor Author

You know cuz I know how much you love TS wrangling.

I'm honestly getting tired of it 😅. I was more than happy when arv took on the "type heirarchy too deep" bug

I don't know how hard it is but I thought people might enjoy creating whatever hierarchy they want there?

Mind if I circle back to this after we have custom mutators w/o reads working end to end?

@aboodman
Copy link
Contributor

aboodman commented Jan 29, 2025 via email

Copy link
Contributor

@arv arv left a comment

Choose a reason for hiding this comment

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

LGTM

@arv
Copy link
Contributor

arv commented Jan 30, 2025

Can you add a test where there isn't a "namespace" too?

const mutators = {
   setTitle: (tx, id: string, title: string) => {
     tx.mutate.issue.update({id, title});
   },  
};

tantaman added a commit that referenced this pull request Jan 31, 2025
tantaman added a commit that referenced this pull request Jan 31, 2025
tantaman added a commit that referenced this pull request Jan 31, 2025
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.

3 participants