<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:59:44 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-2363] $push/$pushAll support for insertion at any position (top/bottom/ordinal)</title>
                <link>https://jira.mongodb.org/browse/SERVER-2363</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Add &lt;tt&gt;$position&lt;/tt&gt; option which takes a positive number.&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;db.col.save({_id:1, a: [3]})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;db.col.update({}, {$push: {a: {$each:[1,2], $position:0 }}}) &lt;/span&gt;&lt;span style=&quot;color: #008200; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;// pushes to front of array&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;If &lt;tt&gt;$position&lt;/tt&gt; is equal to or greater than the array size then it will be ignored and is effectively a push to the end, which is the default behavior if not specified.&lt;/p&gt;

&lt;p&gt;This will allow you to effectively $pop from the top and add to the bottom or vice versa using $slice since you push in either direction.&lt;/p&gt;</description>
                <environment></environment>
        <key id="14225">SERVER-2363</key>
            <summary>$push/$pushAll support for insertion at any position (top/bottom/ordinal)</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="scotthernandez">Scott Hernandez</assignee>
                                    <reporter username="scotthernandez">Scott Hernandez</reporter>
                        <labels>
                    </labels>
                <created>Sat, 15 Jan 2011 19:57:44 +0000</created>
                <updated>Fri, 8 Feb 2019 00:48:04 +0000</updated>
                            <resolved>Fri, 11 Oct 2013 20:58:15 +0000</resolved>
                                                    <fixVersion>2.5.3</fixVersion>
                                    <component>Write Ops</component>
                                        <votes>8</votes>
                                    <watches>11</watches>
                                                                                                                <comments>
                            <comment id="439910" author="auto" created="Fri, 11 Oct 2013 20:55:44 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;scotthernandez&apos;, u&apos;name&apos;: u&apos;Scott Hernandez&apos;, u&apos;email&apos;: u&apos;scotthernandez@gmail.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2363&quot; title=&quot;$push/$pushAll support for insertion at any position (top/bottom/ordinal)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2363&quot;&gt;&lt;del&gt;SERVER-2363&lt;/del&gt;&lt;/a&gt; $push support for insertion at any position&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/967dbe1b27ac6459c15d02c30dd6a0790203d54e&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/967dbe1b27ac6459c15d02c30dd6a0790203d54e&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="159180" author="jan.rie" created="Fri, 31 Aug 2012 08:07:20 +0000"  >&lt;p&gt;Artem, I just added my vote, but perhaps it&apos;s also a good idea to push this ticket info (with short summary onto the mailinglist?) to get attention to it. Also my proposal differs somehow from the initial post and it might be kinda misleading to what is beeing voted for.&lt;/p&gt;

&lt;p&gt;I personally don&apos;t agree with shift/unshift in total, for me it takes more understanding, from a stack/array logic point of view, to understand those and I see those in a broader concept: (not onlty top/bottom)&lt;/p&gt;

&lt;p&gt;Idea for me:&lt;br/&gt;
&quot;$shift&quot; -&amp;gt; shifts any item in question by the stack by (possible negative value for updwards) X positions from current position, either finding it by direct addressing it as &apos;Item2&apos;, or by positional index - if the position is out of reach, the item just drops to the end of the list.&lt;/p&gt;

&lt;p&gt;But this way of course assumes, that you exactly know the position of the element to be moved, and this can of course change if the current information is outdated and there are no reference counters (probably a bad idea, I dunno).&lt;br/&gt;
On the other hand, if one wants a dynamic increasing stack (forwards and backwards) - shifting with &quot;null&quot; value inserts could also be desired, but perhaps sometimes not of course..&lt;/p&gt;

&lt;p&gt;Thats why I came up with the examples&lt;br/&gt;
$pushAt, $popFrom, $pullOnce - cause one can&lt;/p&gt;

&lt;p&gt;in heavy updated documents:&lt;br/&gt;
$pushAt&quot; -&amp;gt; Pushes at exact positon, $pullOnce - removes one existing, but unique, value from the stack/array&lt;/p&gt;

&lt;p&gt;But of course, keeping track of an object position - for example by referencing a index position is kinda risky - assuming anohter element gets pushed at the same position - but we don&apos;t track the previous item has moved one forward (down) in the array. But this might also depend on the use case and $pullOnce may come into play.&lt;/p&gt;

&lt;p&gt;in single documents not affected by massive changes:&lt;br/&gt;
&quot;$popFrom&quot; -&amp;gt; If we we are safe with a document, we tell mongo exactly which position to be removed,&lt;br/&gt;
of course also the &quot;$pullOnce&quot; solution can be used, but this involves scanning data - which might be not neccesary - but I agree that this command is quite special as most of the time one not might know beforehand the actual positon of one item so.&lt;/p&gt;

&lt;p&gt;Anyhow, sorry for this long post so, but I hope it makes sense.&lt;/p&gt;</comment>
                            <comment id="158670" author="artem" created="Thu, 30 Aug 2012 19:06:20 +0000"  >&lt;p&gt;Jan +1 I want $pushAt and $popFrom too. Have you voted for this issue? We need to get more votes to move this issue from &quot;planned but not scheduled&quot; to &quot;Planning Bucket A&quot;&lt;/p&gt;</comment>
                            <comment id="157076" author="jan.rie" created="Mon, 27 Aug 2012 18:42:39 +0000"  >&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;would it be possible to integrate a $pushAt, $popFrom queries, meaning:&lt;br/&gt;
$pushAt - pushes an item to a specific position (most likely an array)&lt;br/&gt;
$popFrom - removes an item from a given position&lt;br/&gt;
both methods should require of course a position operator - most likely an array?&lt;/p&gt;

&lt;p&gt;At the moment &quot;$pull&quot; removes/searches for many values inside an array, but if there is only one (surely) item to be removed, perhaps it would be more performant to have something like&lt;br/&gt;
&quot;$pullOne&quot; or similiar and then exit the operation without touching any subsequent items of an array to increase performance in difference to ordinary &quot;$pull&quot; (seeking through all elements)&lt;/p&gt;

&lt;p&gt;Is this possible?&lt;/p&gt;</comment>
                            <comment id="83080" author="aheckmann" created="Sat, 28 Jan 2012 16:30:48 +0000"  >&lt;p&gt;Agree with $push/$pop/$unshift/$shift semantics being intuitive.&lt;/p&gt;</comment>
                            <comment id="22384" author="eliot" created="Sun, 16 Jan 2011 04:55:01 +0000"  >&lt;p&gt;Not sure if both will happen or one, but marked as related .&lt;/p&gt;</comment>
                            <comment id="22380" author="keithbranton" created="Sun, 16 Jan 2011 02:23:07 +0000"  >&lt;p&gt;@Scott - I&apos;m not aware of any other uses for push in programming besides stacks. In stack semantics &quot;push&quot; means &quot;add item to top of stack&quot;. The current $push operation is consistent with this. The deque is the data structure that supports adding and removing at both ends. The most common names for deque operations in modern languages are $push/$pop/$unshift/$shift. These are at least common to javascript, ruby, PHP (with array_ prefix) and perl. Since Mongo already uses $push and $pop, it makes sense to keep the operations at the other end of the structure consistent with the languages that use push and pop.&lt;/p&gt;

&lt;p&gt;Since $push adds an item to the end of an array, it seems that the end of the array is the top, and the front must, therefore, be the bottom. So $pushToTop would be a very misleading name for an operation that adds an item to the bottom. &lt;/p&gt;

&lt;p&gt;I believe good naming, consistent with common CS concepts, is much more intuitive and lowers the barrier to entry for newbies, but honestly I&apos;m not so concerned with what the modifiers ultimately get called &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; I&apos;m not really a big fan of the names $shift and $unshift either - but I am a very big fan of consistency.&lt;/p&gt;</comment>
                            <comment id="22379" author="scotthernandez" created="Sat, 15 Jan 2011 22:54:50 +0000"  >&lt;p&gt;This issue is independent of your issue/proposal; I am not making the assumption that what your propose will every come to be, or is even good. I&apos;m just asking for improvements to the current features.&lt;/p&gt;

&lt;p&gt;There are many ways to keep backwards compatibility. We can add $pushToTop to the update, or to the $push document.&lt;/p&gt;

&lt;p&gt;(I don&apos;t like $(un)shift*; it is not intuitive. $push with a modifier for direction seems very simple, and works, rather than a new operator/modifier.)&lt;/p&gt;</comment>
                            <comment id="22377" author="keithbranton" created="Sat, 15 Jan 2011 21:31:24 +0000"  >&lt;p&gt;This duplicates much of my ticket: &lt;a href=&quot;http://jira.mongodb.org/browse/SERVER-2362&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;http://jira.mongodb.org/browse/SERVER-2362&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I already requested $unshift with $each support on that ticket which would take care of $push and $pushAll insertion at top. -1 for changing $pushAll at all - it should be deprecated in favor of $push with $each, not enhanced.&lt;/p&gt;

&lt;p&gt;Since $push looks like { $push : &lt;/p&gt;
{ field : value }
&lt;p&gt; } it&apos;s hard to see how that could be changed to support insertion in the top while maintaining backwards compatibility in an elegant way or semantic correctness.&lt;/p&gt;

&lt;p&gt;I&apos;m not sure I understand the benefit of this proposal wrt $addToSet. Is there a use-case that the current $addToSet, and proposed $pushToSet and $unshiftToSet modifiers wouldn&apos;t satisfy? I have documented a couple on 2363 that this proposal would certainly not satisfy.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="14224">SERVER-2362</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="43910">SERVER-6399</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="13143">SERVER-1824</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="13897">SERVER-2191</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="48191">SERVER-6873</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="11744">SERVER-991</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="13576">SERVER-2036</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="130131">SERVER-13521</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="685769">SERVER-39446</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Sat, 15 Jan 2011 21:31:24 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        10 years, 18 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[<s><a href='https://jira.mongodb.org/browse/SERVER-2362'>SERVER-2362</a></s>, <s><a href='https://jira.mongodb.org/browse/SERVER-6399'>SERVER-6399</a></s>]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>justin.labreck@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            10 years, 18 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>aheckmann</customfieldvalue>
            <customfieldvalue>artem</customfieldvalue>
            <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>jan.rie</customfieldvalue>
            <customfieldvalue>keithbranton</customfieldvalue>
            <customfieldvalue>scotthernandez</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrp8jb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrg35z:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7415</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hskemv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>