Aggregation Framework needs to support $addToSet and $push inside a Group expression tree

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Done
    • Priority: Major - P3
    • 2.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, the only 2 accumulators we do not support are $push and $addToSet.

      We could implement these in a simple manner with the following syntax.

      For $push:

      { $group: {_id: "$State", Cities: { $push: "$City" } } }
      .Group(x => x.State, g => new 
      { 
        _id = g.Key,
        Cities = new List<string>(g.Select(x => x.City))
      }
      

      And for $addToSet:

      { $group: {_id: "$State", Cities: { $addToSet: "$City" } } }
      .Group(x => x.State, g => new
      { 
        _id = g.Key,
        Cities = new HashSet<string>(g.Select(x => x.City))
      }
      

            Assignee:
            Craig Wilson
            Reporter:
            Craig Wilson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: