docs(examples): demonstrate orm in worker transactions#799
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe /tx/commit handler was refactored to use a transaction-scoped ORM client (create/update), with a ChangesORM-based Transaction Implementation for /tx/commit Route
Sequence Diagram(s)sequenceDiagram
participant Handler as tx_commit_handler
participant Validator as isChar36
participant Transaction as withTransaction
participant OrmClient as createOrmClient
participant Database as ORM/DB
Handler->>Validator: validate userId (length 36)
Validator-->>Handler: Char<36> userId
Handler->>Transaction: invoke transactional callback
Transaction->>OrmClient: build ORM client from tx runtime
OrmClient->>Database: create Post
OrmClient->>Database: update User
Database-->>Transaction: return post and user
Transaction-->>Handler: return committed, user, post
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Seven Du <5564821+medz@users.noreply.github.com>
e1920af to
1c5300a
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
SevInf
left a comment
There was a problem hiding this comment.
Hi @medz!
I think correct way to do this would be exposing transaction on postgressServeless facade the same way normal facade does. withTransaction + runtime combination is more of a low-level building block, higher-level transaction is what we meant to expose to end users. It's omission from serverless facade is not some grand design decision, I think we simply forgot.
You could contribute it yourself if you are interested, but fine if it's not — we'd fix it ourself in this case
|
duplicate #695 |
Linked issue
n/a — small example change
Summary
The Cloudflare Worker example now shows the ORM client being created from a transaction-scoped runtime, so users can see how ORM writes participate in the same
withTransactionbody. The ORM client factory acceptsRuntimeQueryable, which lets callers pass either the top-level runtime or a transaction scope.Testing performed
pnpm --dir examples/prisma-next-cloudflare-worker typecheckpnpm --dir examples/prisma-next-cloudflare-worker lintpnpm testinexamples/prisma-next-cloudflare-workerwith Docker PostgresSkill update
n/a — example-only change
Checklist
git commit -s) per the DCO. The DCO status check will block merge if any commit is missing aSigned-off-by:trailer.n/aif the change is doc-only / refactor with no behavioural delta).n/a — internal only).Notes for the reviewer
The example keeps the per-request runtime usage unchanged; only the ORM client factory parameter is widened so transaction scopes can be passed to the same helper.
Summary by CodeRabbit
New Features
Improvements
Tests
Documentation