Type-safe $set with positional operator "$"

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.9.2
    • Component/s: API
    • None
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None

      Currently the only way to use a positional operator & for updating a field in embedded array is to use the not type safe Update.Set with manually constructing the statement like:

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      Update.Set("MyArray.$.Value", newVal);
      

      A method can be added to the generic Update<TDocument> and UpdateBuilder<TDocument> to avoid hard-codding strings (there is already similar approach with Query<T>.ElemMatch):

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      Update<MyDocument>.SetPositional(d => d.MyArray, a => a.Value, newVal);
      

              Assignee:
              Unassigned
              Reporter:
              Svetoslav Milenov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: