Support field-level and range filters in getEmDashCollection where clause #1065
Glacier-Luo
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
The
whereoption ongetEmDashCollectioncurrently only processes taxonomy-based keys (via JOIN). Non-taxonomy field names are silently discarded, forcing sites with large content libraries to load entire collections into memory and filter in JavaScript.Use case
A fiction serialization site with ~4000 chapters spanning 10+ years. The timeline page needs to filter by year (
published_atrange) and by series (field exact match). Without SQL-level field filtering, the only options are:.filter()— wasteful on large collectionsgetDb()— loses preview, visual editing, byline hydration, and request cachingProposal
Extend
WhereValueto support three forms:string— exact match (AND col = ?)string[]— multi-value match (AND col IN (?, ?, ...)){ gt?, gte?, lt?, lte? }— range comparisonsNon-taxonomy keys in
wheregenerate parameterized SQL conditions viabuildFieldConditions(). Field names are validated againstFIELD_NAME_PATTERNto prevent injection. Values use Kysely'ssqltagged template for parameter binding.Backward compatible — existing taxonomy filtering via JOIN is unchanged.
Example usage
I have a working implementation with 12 unit tests and a changeset ready if this is accepted.
Beta Was this translation helpful? Give feedback.
All reactions