Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-29406

syntactic sugars for aggregations

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: None
    • None
    • Query
    • Fully Compatible
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      IMHO writing aggregation for simple join operations are big efforts and some syntax improvements will be good. I know JSON has limitations and lots of stuff that I don't know about server core. But let me express my ideas:

      For instance basic calculations and string concats:

      db.collection.find({}, {_id: 1, name: 1, "nonExistField": {$statement: "1 + 4"}});
      

      for just concatanation:

      db.collection.find({}, {_id: 1, name: 1, "newField": {$concat: "$firstName + ' ' + $lastName"}});
      

      or sum operations:

      db.collection.find({}, {_id: 1, "total": {$sum: "$age"}});
      

      and for join operations:

      this is a sample User collection:

      {
        "_id" : ObjectId("592e75ebe076c31cee205b72"),
        "name": "Test User",
        "tags": [
          DBRef("tag", ObjectId("592e75ebe076c31cee205b77")),
          DBRef("tag", ObjectId("592e75ebe076c31cee205b78"))
        ]
      }
      
      {
        'tags.$join': {'$elemMatch': {'name': {'$regex': '^test', '$options': 'i'}}}
      }
      

      Server can convert my query to an aggregation query but as a simple user It's a big effort.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            firatkucuk F?rat KÜÇÜK
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: