Repository navigation
Fix meditation locale filtering - #206
Merged
Merged
Conversation
Add beforeOperation hook that filters meditations by their locale select field on find and count operations. Skips filtering for findByID (always returns specific document) and locale=all requests. Closes #202 Co-Authored-By: Claude Opus 4.5 <[email protected]>
Tests cover: locale-specific find/count, locale=all bypass, findByID locale mismatch, where clause composition, and default English locale behavior. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Update localization.md and architecture.md to accurately describe the beforeOperation hook implementation instead of the incorrect beforeFind/beforeCount references. Co-Authored-By: Claude Opus 4.5 <[email protected]>
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
filterMeditationsByLocalebeforeOperation hook that filters meditations by theirlocaleselect field onfindandcountoperationsbeforeFind/beforeCounthooksHow it works
Each meditation belongs to a single locale via a select field (unlike other collections that use PayloadCMS field-level localization). The hook intercepts
findandcountoperations and adds{ locale: { equals: <requestedLocale> } }to thewhereclause.Skipped for:
findByID— always returns the specific documentlocale=all— returns all meditations regardless of localeCloses #202
Test plan
locale: 'en'locale: 'cs'locale: 'all'findByIDreturns document regardless of locale mismatchwhereclauses (AND logic)Test Results
🤖 Generated with Claude Code