[DOCS-4302] Inclusion of array slice may be specified with exclusion of other fields Created: 07/Nov/14 Updated: 30/Oct/23 Resolved: 24/Jan/18 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual |
| Affects Version/s: | None |
| Fix Version/s: | Server_Docs_20231030 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | rohit.nijhawan@10gen.com | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | bite-sized | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
mongodb 2.6 |
||
| Participants: | |
| Days since reply: | 6 years, 3 weeks, 1 day ago |
| Story Points: | 0.25 |
| Description |
|
In the following URL, we explain how we may use projection on fields to limit the output structure of a document. http://docs.mongodb.org/manual/tutorial/project-fields-from-query-results/ While one may use $slice to limit an array to a few of its elements, it is possible to select parts of that array, but also remove other fields as such db.t.insert({_id:1, name:'mongouser', age:100, message:'try the new mongodb version 2.6', v:[1,2,3,4,5,6]}) Then try db.t.find({},{name:1, age:1, message:0}) Please modify You cannot combine inclusion and exclusion semantics in a single projection with the exception of the _id field. |
| Comments |
| Comment by Kay Kim (Inactive) [ 24/Jan/18 ] |
|
Was fixed a while ago. |