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

$slice from index to end of array

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Environment:
      All
    • Query Optimization

      Would be nice to be able to get from an array all items after a given index, without knowing the length of the array. For example:

      { _id :1,
      foo: [1, 2, 3, 4, 5]
      }

      > db.test.find( {}, { foo:

      { $slice: [1, $end] }

      } )
      >

      { _id: 1, foo: [2, 3, 4, 5] }

      Currently, it seems you can only do this by:
      1. Knowing what the length is and doing this: db.test.find( {}, { foo:

      { $slice: [1, n] }

      } )
      2. Using JavaScript in the query
      3. Picking an arbitrarily high number to use as the limiter: db.test.find( {}, { foo:

      { $slice: [1, 1000] }

      } )

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            kmorales Kirk Morales
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: