[SERVER-2393] $slice from index to end of array Created: 22/Jan/11  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Trivial - P5
Reporter: Kirk Morales Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

All


Assigned Teams:
Query Optimization
Participants:

 Description   

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] }

} )


Generated at Thu Feb 08 02:59:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.