[DOCS-3498] Comment on: "manual/reference/operator/update/position.txt" Created: 29/May/14  Updated: 03/Nov/17  Resolved: 30/May/14

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: 01112017-cleanup

Type: Improvement Priority: Major - P3
Reporter: Docs Collector User (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: http://docs.mongodb.org/manual/reference/operator/update/position/#up._S_position
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.76.4 (KHTML, like Gecko) Version/7.0.4 Safari/537.76.4
Referrer: http://docs.mongodb.org/manual/reference/operator/update/push/
Screen Resolution: 1920 x 1200
repo: docs
source: reference/operator/update/position


Participants:
Days since reply: 9 years, 37 weeks, 6 days ago

 Description   

Error in the documentation :

The results to the example "Add Elements at the Start of the Array" should be

{ "_id" : 1, "scores" : [ 100, 50, 60, 70 ] }

instead of

{ "_id" : 1, "scores" : [ 50, 60, 70, 100 ] }

.



 Comments   
Comment by Kay Kim (Inactive) [ 30/May/14 ]

Thank you so much for taking the time to file this ticket. I believe the results are correct as they are in the documentation:

The new values 50, 60, 70 are pushed into the start of the scores array (array index position 0).

> db.students.insert( { "_id" : 1, "scores" : [ 100 ] })
WriteResult({ "nInserted" : 1 })
> db.students.update( { _id: 1 },
                    { $push: { scores: {
                                          $each: [ 50, 60, 70 ],
                                          $position: 0
                                        }
                              }
                     }
                   )
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.students.find()
{ "_id" : 1, "scores" : [ 50, 60, 70, 100 ] }

Generated at Thu Feb 08 07:45:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.