Skip to content
Skillv1.0.0

mongodb-changestream-field-filter

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.

by kjuhwa(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from kjuhwa/skills-hub (skills/backend/mongodb-changestream-field-filter/SKILL.md). Install upstream with npx skills add kjuhwa/skills-hub --skill mongodb-changestream-field-filter. Copyright stays with the author.

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

  1. Register listener via Spring Data MongoDB (reactive or blocking driver).
  2. Branch on OperationType: INSERT / DELETE → always relevant.
  3. UPDATEupdatedFields = event.getUpdateDescription().getUpdatedFields().
  4. Exact check: updatedFields.containsKey("groupId").
  5. Nested/wildcard: updatedFields.keySet().stream().anyMatch(k -> k.startsWith("tags.")).
  6. Combine with OR over the "relevant fields" set; return the boolean.
  7. Not relevant → log TRACE and skip. Relevant → delegate to processor.
  8. Persist resumeToken so reconnection skips already-seen events.

Counter / Caveats

  • updatedFields is keyed by dotted path at the leaf changed. A whole-subdoc replace shows as "parent", not "parent.child" — handle both.
  • Full-document replaces ($set on 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-resubscribe knowledge.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/kjuhwa-skills-hub-mongodb-changestream-field-filter/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

kjuhwa-skills-hub-mongodb-changestream-field-filter.ocm.jsonjson
{
  "ocm": "1",
  "id": "kjuhwa-skills-hub-mongodb-changestream-field-filter",
  "kind": "skill",
  "name": "mongodb-changestream-field-filter",
  "description": "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.",
  "publisher": "kjuhwa",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "backend",
      "mongodb",
      "changestream",
      "field",
      "filter",
      "github"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "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."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "github",
      "repository": "https://github.com/kjuhwa/skills-hub",
      "path": "skills/backend/mongodb-changestream-field-filter/SKILL.md",
      "ref": "b8e7275ea024cc3f9d8551b41aa9ebf89b464cd1",
      "url": "https://github.com/kjuhwa/skills-hub/blob/b8e7275ea024cc3f9d8551b41aa9ebf89b464cd1/skills/backend/mongodb-changestream-field-filter/SKILL.md",
      "key": "kjuhwa/skills-hub/skills/backend/mongodb-changestream-field-filter/SKILL.md"
    }
  },
  "instructions": "# MongoDB Change Stream Field Filter\n\n## Shape\n\nListener receives `ChangeStreamDocument`. For `UPDATE`, read `updateDescription.updatedFields` (a BsonDocument of `dottedPath → value`). Return a boolean `isRelevant` before handing off to the expensive processor.\n\n## Steps\n\n1. Register listener via Spring Data MongoDB (reactive or blocking driver).\n2. Branch on `OperationType`: `INSERT` / `DELETE` → always relevant.\n3. `UPDATE` → `updatedFields = event.getUpdateDescription().getUpdatedFields()`.\n4. Exact check: `updatedFields.containsKey(\"groupId\")`.\n5. Nested/wildcard: `updatedFields.keySet().s",
  "cost": {
    "context_tokens": 333
  }
}

Fetch it by URL: GET /api/v1/registry/kjuhwa-skills-hub-mongodb-changestream-field-filter/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.