Re: Is array index position in MongoDB document guaranteed to be maintained for operations?

From: Mayank Jain <firesofmay@xxxxxxxxx>
To: mongodb-user <mongodb-user@xxxxxxxxxxxxxxxx>
Date: Mon, 25 Apr 2016 01:34:12 -0700 (PDT)
Why ads?
I thought the same but just wanted to make sure since it does not say this 
explicitly.
Thanks.

On Monday, April 25, 2016 at 12:54:11 PM UTC+5:30, Rhys Campbell wrote:

From the manual...

"The $position modifier specifies the location in the array at which the 
$push 
<https://docs.mongodb.org/manual/reference/operator/update/push/#up._S_push> operator 
insert elements. Without the $position modifier, the $push 
<https://docs.mongodb.org/manual/reference/operator/update/push/#up._S_push> operator 
inserts elements to the end of the array. See $push modifiers 
<https://docs.mongodb.org/manual/reference/operator/update/push/#push-modifiers> for 
more information."


https://docs.mongodb.org/manual/reference/operator/update/position/#up._S_position

I would say that this means order will be preserved in insert order if you 
don;t use the $position modifier. There's always the option of using the 
$position modifier with an index if you wish to be explicit. 


-- 
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
--- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/200eab55-8c49-4033-acd5-8d2e5dd4c0ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Why ads?