Mongodb changestream field filter
Skill kjuhwa/skills-hub/skills/backend/mongodb-changestream-field-filter
Self-correcting knowledge corpus for Claude Code — 9 stable shape clusters, bias-correction pipeline baked into contribution flow. 47 papers, 45 techniques, 1.1k skills.
npx -y skills add kjuhwa/skills-hub --skill mongodb-changestream-field-filterAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Filter MongoDB change stream UPDATE events by inspecting updateDescription.updatedFields so irrelevant mutations do not trigger downstream work; INSERT/DELETE fall through as always-relevant.
SKILL.md
1.9 KB, 314 tokens by cl100k_base, as published. Nobody here has run it
MongoDB Change Stream Field Filter
Shape
Listener receives ChangeStreamDocument. For UPDATE, read updateDescription.updatedFields (a BsonDocument of dottedPath → value). Return a boolean isRelevant before handing off to the expensive processor.
Steps
- Register listener via Spring Data MongoDB (reactive or blocking driver).
- Branch on
OperationType:INSERT/DELETE→ always relevant. UPDATE→updatedFields = event.getUpdateDescription().getUpdatedFields().- Exact check:
updatedFields.containsKey("groupId"). - Nested/wildcard:
updatedFields.keySet().stream().anyMatch(k -> k.startsWith("tags.")). - Combine with OR over the "relevant fields" set; return the boolean.
- Not relevant → log TRACE and skip. Relevant → delegate to processor.
- Persist
resumeTokenso reconnection skips already-seen events.
Counter / Caveats
updatedFieldsis keyed by dotted path at the leaf changed. A whole-subdoc replace shows as"parent", not"parent.child"— handle both.- Full-document replaces (
$seton root) may surface every field as "updated"; treat as relevant. - Never skip DELETEs on field filter — there are no fields to inspect.
- Network hiccup / replica-set election → stream goes silent without exception; pair with
mongodb-changestream-resubscribeknowledge.
What ships with it: 1 file
602 B alongside SKILL.md
- content.md602 B