Skip to content

Update operator descriptions reference wrong documentation category #570

@tnaum-ms

Description

@tnaum-ms

Problem

Six update operators in packages/documentdb-constants/src/updateOperators.ts have hover descriptions that are biased toward another operator category (accumulator, aggregation stage, or array expression). The documentation pages themselves are correct and comprehensive — they cover both the primary category usage and the update operator usage on the same page — but the scraper extracts only the opening sentence, which is category-specific.

The links are correct and should be kept. Only the hover descriptions need overrides.

Verification: What the Published Docs Actually Say

Each page was fetched and verified. All but $unset cover the update use case:

Operator Published Page Page Intro (scraped for hover) Update Coverage on Page Our Current Hover Text
$min accumulators/$min "The $min operator is used within aggregation stages like $group..." ✅ Syntax section + Examples 4–8 cover field update operator Retrieves the minimum value for a specified field
$max accumulators/$max "The $max operator returns the maximum value of a set of input values." ✅ Syntax section + Examples 4–8 cover field update operator The $max operator returns the maximum value from a set of input values.
$set aggregation/$set "The $set operator updates an existing field or creates a new field..." ✅ ALL 5 examples are updateOne() calls The $set operator in Azure DocumentDB updates or creates a new field with a specified valueAlready correct
$unset aggregation/$unset "The $unset stage in the aggregation pipeline is used to remove specified fields..." ❌ Only aggregation pipeline examples — does NOT cover {$unset: {field: ""}} update syntax The $unset stage in the aggregation pipeline is used to remove specified fields from documents.
$slice array-expression/$slice "The $slice operator is used to return a subset of an array..." ✅ Example 2: "Slice with $push" covers array update modifier The $slice operator returns a subset of an array from any element onwards in the array.
$sort aggregation/$sort "The $sort stage in the aggregation pipeline is used to order the documents..." ✅ Example 3: "Sorting an array of objects" uses $push with $sort in updateOne() The $sort stage in the aggregation pipeline is used to order the documents in the pipeline by a specified field or fields.

What Needs to Change

Action: Add description overrides in operator-overrides.md

Keep the existing links — the pages are correct. Only override the hover descriptions to be update-context-specific:

Operator Current Hover (scraped) Proposed Override
$min "Retrieves the minimum value for a specified field" "Updates the field only if the specified value is less than the existing field value."
$max "The $max operator returns the maximum value from a set of input values." "Updates the field only if the specified value is greater than the existing field value."
$set (already correct — no override needed)
$unset "The $unset stage in the aggregation pipeline is used to remove specified fields from documents." "Removes the specified field from a document."
$slice "The $slice operator returns a subset of an array from any element onwards in the array." "Limits the number of elements in an array during a $push operation."
$sort "The $sort stage in the aggregation pipeline is used to order the documents in the pipeline by a specified field or fields." "Sorts the elements of an array during a $push operation."

Note on $unset

$unset is the only operator where the published documentation page genuinely does not cover the update operator use case. The page only shows aggregation pipeline examples. This is a minor documentation gap — consider filing an upstream issue against MicrosoftDocs/azure-databases-docs to add update examples to the $unset page.

Implementation

  1. Edit packages/documentdb-constants/resources/overrides/operator-overrides.md
  2. Add description overrides for $min, $max, $unset, $slice, $sort (skip $set)
  3. Run npm run generate to regenerate
  4. Verify src/updateOperators.ts has the corrected descriptions
  5. Links remain unchanged

Context

Identified during PR #508 review (Finding H3). The scraper correctly falls back to alternative category pages and marks them with // inferred from another category comments. The problem is only the first-sentence extraction producing category-biased hover text.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions