For AI agents: the complete documentation index is available at https://silt-db.dev/llms.txt, the full documentation bundle is available at https://silt-db.dev/llms-full.txt, and this page is available as Markdown at https://silt-db.dev/reference/updates.md.

Update support

Use the MongoDB update operator reference for syntax and examples. This page records Silt's supported forms and restrictions; selection and mutation run in SQLite.

upsert: true inserts when nothing matches. It seeds supported equality predicates from the filter, including dotted paths and $and, before applying the update. Conflicting equality paths fail. Replacement upserts retain an equality-filter _id and reject a conflicting replacement ID. See driver write results for result fields.

Mongo API updateMany preserves earlier successful writes if a later document fails outside a transaction. The core Silt API keeps insertMany and updateMany atomic across the operation. See batch behavior.

Implemented operators

FamilySupported behavior
$set, $unsetExact value replacement including objects/null; dotted paths; missing-parent construction; array element unset becomes null.
$inc, $mulNumeric fields, missing-field initialization, numeric type checks, finite-result checks.
$min, $maxNative SQL BSON-style ordering over the JSON domain, including ordered objects and nested arrays.
$renameMove/replace fields through nested objects; missing source no-op; rejects traversal through arrays.
$setOnInsertApplied only to synthesized upsert documents; still participates in path-conflict validation.
$pushSingle values and $each; positive/negative $position; $sort on complete values or multiple document fields; positive/negative/zero $slice; modifier processing order matches MongoDB.
$addToSetWhole-value equality; each-input deduplication; preserves existing duplicates and object field-order distinctions.
$pop, $pull, $pullAllEndpoint removal, query-based removal, whole-value equality removal; missing-array no-op; nonarray error.
$bitand, or, xor; missing-field zero initialization; safe integer operands and integral safe numeric fields (including integral results of earlier arithmetic).
Positional paths$[], $[identifier], compound array filters and nested positional arrays. Filters read the original document even when several fields are updated.
Numeric array pathsExplicit indices, leading zeros, and null padding when extending an array. Numeric components remain literal keys when the parent is an object.
Update pipelines$set, $addFields, $unset, $project, $replaceRoot, $replaceWith, using the aggregation compiler. Fields within a stage read the same input document.

An existing _id must be preserved. Setting it to an equal value is allowed; $rename involving _id is rejected. Pipeline updates that omit _id implicitly restore its original value, as MongoDB does.

Subqueries bind intermediate values once. Array mutations use json_each and ordered JSON aggregation. Native SQL guards abort invalid per-document transformations. Core multi-document updates and explicit Mongo API transactions roll back the entire operation or transaction on failure.

Boundaries and costs

  • Input and stored values use the project's JSON domain. BSON dates, ObjectId, decimal, binary, and nonfinite numbers are not supported. Consequently $currentDate is unavailable.
  • Legacy query-bound positional $ is explicitly rejected; use $[] or filtered $[identifier].
  • Different positional identifiers, or differently spelled numeric components, whose normalized update paths could overlap are explicitly rejected. This conservative check also rejects some disjoint-filter updates that MongoDB can execute. Identical selectors on different child fields are supported.
  • MongoDB-specific error codes/messages are not reproduced. Some document-dependent validation errors surface as SQLite malformed JSON; the failing document is not changed; batch rollback follows the API and transaction rules above.
  • Compound $push.$sort uses native pairwise ranking to preserve value-order semantics. It is quadratic in the updated array length; it is intended for modest arrays, not as an indexed collection-sort substitute.
  • Very large explicit array indices materialize the required null padding in SQLite and can be expensive. Large/deep statements remain subject to SQLite's compilation and nesting limits.
  • modifiedCount counts final JSON changes. MongoDB reports 1 for a pipeline that removes _id and implicitly restores it even when the final document is identical; Silt reports 0 in that narrow case.
  • Unknown options, unspecified operators, and unsupported aggregation expressions fail explicitly. See driver options for the accepted Mongo API options.

Verification

Focused update tests and live MongoDB comparisons cover values, paths, arrays, rollback, upsert, and result counts. The _id pipeline-count exception above is tracked explicitly. See testing and compatibility evidence for the suites and recorded results.