-
-
Notifications
You must be signed in to change notification settings - Fork 38
document externalIdMapping #480
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe documentation for the RESTful API handler was updated to describe a new optional configuration option, Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
docs/reference/server-adapters/api-handlers/rest.mdx (4)
104-104: Fix grammar/wording and clarify intentTighten the wording, fix typos, and clarify what the mapping targets.
- Optional. An `Record<string, string>` value that provides a mapping from model names (as defined in ZModel) to unique contraint name. This is useful when you for example want to expose natural keys in place of a surrogate keys: + Optional. A `Record<string, string>` that maps model names (as defined in ZModel) to a unique constraint (field or composite) used as the external identifier in URLs. Useful when you want to expose natural keys instead of surrogate keys:
106-113: Polish the example comment (typos, phrasing, and URL placeholder)Minor corrections for clarity and accuracy.
- // Expose tags by unique name and not by ID, ie. /tag/blue intead of /tag/id + // Expose Tag resources by unique name rather than by ID (i.e., /tag/blue instead of /tag/:id) RestApiHandler({ externalIdMapping: { Tag: 'name' } })
115-115: Correct typos and clarify compound unique behaviorFix spelling; make the limitation precise; tie behavior to Compound ID documentation.
- Currentlly it is not possible to use custom index names. This also works for compound unique contraints just like for [compound IDs](#compound-id-fields). + Currently, custom unique index/constraint names are not supported. Compound unique constraints are supported; the URL uses the same underscore-joined format described in [Compound ID Fields](#compound-id-fields) and inherits the same limitations.
102-115: Clarify how to reference a compound unique constraint inexternalIdMappingThe value type is
Record<string, string>, but for compound uniques it’s not obvious what string is expected (field list? implicit constraint identifier?). Please add a concrete example for a compound unique and specify the expected syntax.For example, if the schema defines:
model Article { id Int @id @default(autoincrement()) slug String locale String @@unique([slug, locale]) }
- If the mapping expects a comma-separated field list, consider documenting this explicitly and add an example like:
RestApiHandler({ externalIdMapping: { Article: 'slug,locale' } }) // e.g., GET /article/hello-world_en
- If it expects a different identifier (e.g., an implicit name), please document the exact format and show how the URL is formed, including the underscore-join and its limitations.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/reference/server-adapters/api-handlers/rest.mdx(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/reference/server-adapters/api-handlers/rest.mdx
[grammar] ~104-~104: Ensure spelling is correct
Context: ... names (as defined in ZModel) to unique contraint name. This is useful when you for example wan...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~115-~115: Ensure spelling is correct
Context: ... Tag: 'name' } }) ``` Currentlly it is not possible to use custom index ...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~115-~115: Ensure spelling is correct
Context: ...es. This also works for compound unique contraints just like for [compound IDs](#compound-...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
ymc9
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks! I'll merge it after a new version is published.
adds docs for zenstackhq/zenstack#2188
Summary by CodeRabbit
externalIdMappingconfiguration.