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
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
$currentDateis 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.$sortuses 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.
modifiedCountcounts final JSON changes. MongoDB reports1for a pipeline that removes_idand implicitly restores it even when the final document is identical; Silt reports0in 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.