[SERVER-754] way to return region of an embedded array Created: 15/Mar/10 Updated: 12/Jul/16 Resolved: 16/Apr/10 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | 1.5.1 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Eliot Horowitz (Inactive) | Assignee: | Mathias Stearn |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
db.foo.find( {} , { comments : { $slice : [ 20,40] }} ) |
| Comments |
| Comment by auto [ 16/Apr/10 ] |
|
Author: {'login': 'RedBeard0531', 'name': 'Mathias Stearn', 'email': 'mathias@10gen.com'}Message: $slice operator for projections (second arg to find) |
| Comment by Eliot Horowitz (Inactive) [ 13/Apr/10 ] |
|
i'd say apis are split 50/50 on min,max vs start,len for list substring ruby is start,len and our most common language, so maybe that should be the tie breaker |
| Comment by Mathias Stearn [ 13/Apr/10 ] |
|
I think simple numbers should work like this this: $slice: 5 -> first 5 If there is an array is it better to do range or skip-limit? |
| Comment by Michael Dirolf [ 13/Apr/10 ] |
|
could try to mimic the python slice syntax: taking it all the way, could even do: |
| Comment by Ash Berlin [ 13/Apr/10 ] |
|
> slice : 3 // first 3? My PoV as a user is I'd expect this to skip the first 3, i.e return 3..end -3 returning last 3 makes sense to me My 2p |
| Comment by Dwight Merriman [ 13/Apr/10 ] |
|
$slice : 3 // first 3? |
| Comment by Dwight Merriman [ 13/Apr/10 ] |
|
{ arr : { $slice : [20,40] }} ? |