<!-- 
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-2362] Add new Deque/Set operation modifiers</title>
                <link>https://jira.mongodb.org/browse/SERVER-2362</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;$unshift - like $push, but to the start of the array, and with support for the $each construct like $addToSet.&lt;/p&gt;

&lt;p&gt;$pushToSet - like $push in that the supplied item(s) will end up at the end of the set in the supplied order - maintaining set semantics by removing pre-existing matching elements. Should support the $each construct.&lt;/p&gt;

&lt;p&gt;$unshiftToSet - just like $pushToSet, but adds items at the start of the array.&lt;/p&gt;

&lt;p&gt;The next two are more &quot;nice to have&apos;s&quot;.&lt;/p&gt;

&lt;p&gt;$push - add support for the $each construct - $pushAll could then be deprecated&lt;/p&gt;

&lt;p&gt;$shift - just like $pop with reversed sign, i.e. {$pop:{a:-1}} is the same as {$shift:{a:1}}&lt;/p&gt;</description>
                <environment></environment>
        <key id="14224">SERVER-2362</key>
            <summary>Add new Deque/Set operation modifiers</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</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="12300">Won&apos;t Do</resolution>
                                        <assignee username="backlog-server-query">Backlog - Query Team</assignee>
                                    <reporter username="keithbranton">Keith Branton</reporter>
                        <labels>
                    </labels>
                <created>Sat, 15 Jan 2011 18:42:44 +0000</created>
                <updated>Thu, 6 Apr 2023 16:05:22 +0000</updated>
                            <resolved>Sat, 29 Jun 2019 07:35:33 +0000</resolved>
                                                                    <component>Write Ops</component>
                                        <votes>13</votes>
                                    <watches>16</watches>
                                                                                                                <comments>
                            <comment id="2305628" author="asya" created="Sat, 29 Jun 2019 07:35:33 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-40381&quot; title=&quot;Add the ability to specify a pipeline to an update command&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-40381&quot;&gt;&lt;del&gt;SERVER-40381&lt;/del&gt;&lt;/a&gt; implemented support for aggregation expressions to specify update for 4.2.&#160;&lt;/p&gt;

&lt;p&gt;You can see some examples &lt;a href=&quot;https://docs.mongodb.com/master/reference/command/update/index.html#update-command-example-agg&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This can be done by setting the array to its new value using various aggregation array expressions.   I believe this can handle all of the examples/use cases that were mentioned in the comments.   In particular, $size, $slice, and set operators would be useful.&lt;/p&gt;</comment>
                            <comment id="1006422" author="dandv" created="Sat, 15 Aug 2015 04:10:48 +0000"  >&lt;p&gt;I would like to see $unshift implemented simply as an alias to $position: 0, but without requiring $each, which doesn&apos;t read intuitively.&lt;/p&gt;

&lt;p&gt;Filed a separate ticket at &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-19974&quot; title=&quot;Add $unshift modifier as alias to $push $each $position: 0&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-19974&quot;&gt;SERVER-19974&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="305431" author="justanyone" created="Wed, 3 Apr 2013 21:11:03 +0000"  >&lt;p&gt;Echo TP Diffenbach&apos;s comment.  This is EXACTLY what we&apos;re doing now, storing data in an array:&lt;/p&gt;

&lt;p&gt;ts=timestamp, val=value&lt;/p&gt;

&lt;p&gt;vals : [  &lt;span class=&quot;error&quot;&gt;&amp;#91;ts1,val1&amp;#93;&lt;/span&gt;, &lt;span class=&quot;error&quot;&gt;&amp;#91;ts2,val2&amp;#93;&lt;/span&gt;, &lt;span class=&quot;error&quot;&gt;&amp;#91;ts3,val3&amp;#93;&lt;/span&gt;, ... ]&lt;/p&gt;

&lt;p&gt;Every minute, I&apos;m adding new data with $push, onto the end of the array.&lt;/p&gt;

&lt;p&gt;But, to keep record sizes at 4k, I have splitRecords.py.  It moves off the oldest 125 datapoints to their own document (all during which time a new value may come in while I&apos;m busy pulling this data out).  So, I&apos;m pulling from the front of the array.  I only get the option of one element at a time.  I&apos;d like to pull an arbitrary number of elements from the front of the array.&lt;/p&gt;

&lt;p&gt;My temporary, and ugly, workaround is to use $pullAll and reference the exact elements to be pulled.  I&apos;m very lucky in that my data is unique and I can do this.  But, it&apos;s ugly - I only need to pull n elements off the front of the array, not search for them individually and remove each specially.  &lt;/p&gt;
</comment>
                            <comment id="289637" author="tpdi" created="Thu, 14 Mar 2013 22:25:17 +0000"  >&lt;p&gt;Here&apos;s my use case, and I think it&apos;s compelling.&lt;/p&gt;

&lt;p&gt;When I have an array of history, I want to be able to distinguish one item as the current value. Whether that&apos;s the zeroth or the last element doesn&apos;t much matter.&lt;/p&gt;

&lt;p&gt;Given db.zeroth.insert( { x:1, statusHistory: [ &lt;/p&gt;
{ status : &quot;approved&quot;}
&lt;p&gt;, &lt;/p&gt;
{ status : &quot;draft&quot;}
&lt;p&gt;, &lt;/p&gt;
{status : &quot;created&quot;}
&lt;p&gt;]}),&lt;/p&gt;

&lt;p&gt;I can reference the zeroth element as the &quot;current&quot; value:&lt;/p&gt;

&lt;p&gt;db.zeroth.find( &lt;/p&gt;
{ &quot;statusHistory.0.status&quot; : &quot;approved&quot; }
&lt;p&gt;); // find all currently in approved status&lt;/p&gt;

&lt;p&gt;So I&apos;m storing the array newest to oldest so that I can reference the newest (current) status at element zero.&lt;/p&gt;

&lt;p&gt;But now I can&apos;t easily add a newer status, because it would be pushed to the end of the array.&lt;/p&gt;

&lt;p&gt;If instead I store the array oldest to newest, I can easily push newer statuses, but I can&apos;t easily reference the newest.&lt;/p&gt;

&lt;p&gt;The Mongo solution to issues like this with arrays this seems to be &quot;store it (special element, array length, whatever) explicitly as another attribute or sub-document&quot;. But that ends up either duplicating data, or fracturing it into a current part and a history part, and it doesn&apos;t play well with the New Aggregation Framework (e.g., if I wanted to $unwind all status, including the current).&lt;/p&gt;

&lt;p&gt;But unless I duplicate data, I have no way to be able to query and update the same position: with one array, I can query element zero, or I can push onto the end, but there&apos;s no position that I can explicitly both query and update.&lt;/p&gt;
</comment>
                            <comment id="162794" author="benb7760" created="Tue, 11 Sep 2012 02:26:04 +0000"  >&lt;p&gt;Being able to insert an item at the start of an array would be very useful for me for some applications I will be developing over the next few years&lt;/p&gt;</comment>
                            <comment id="30514" author="chrishanks" created="Sat, 30 Apr 2011 23:10:05 +0000"  >&lt;p&gt;These would be great - the ability to use $pushToSet on a fixed-size array would really help me with a problem I&apos;m having.&lt;/p&gt;</comment>
                            <comment id="22383" 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="22378" author="keithbranton" created="Sat, 15 Jan 2011 22:15:15 +0000"  >&lt;p&gt;Scott Hernandez has pointed out that $pushToSet could be performed with a combination of $pull(All) and $push(All) once &lt;a href=&quot;http://jira.mongodb.org/browse/SERVER-1050&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;http://jira.mongodb.org/browse/SERVER-1050&lt;/a&gt; is implemented.&lt;/p&gt;

&lt;p&gt;On further reflection I currently have no use-cases for &quot;pushing&quot; to both ends of any single array, so the $unshift operations could be worked around by storing all the relevant arrays backwards. Presumably that would perform slightly better too since fewer items would need to be moved when a $push happens than with $unshift.&lt;/p&gt;

&lt;p&gt;I still think this proposal is more intuitive, though, and all my user-sorted arrays are pretty small so I doubt I&apos;d notice the performance difference. Seeing the same order in the shell as my application uses is more obvious when debugging, so if it&apos;s not to difficult to do I&apos;m still asking &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;&lt;/p&gt;</comment>
                            <comment id="22375" author="keithbranton" created="Sat, 15 Jan 2011 18:52:55 +0000"  >&lt;p&gt;$pushToSet would be a key component in solving the use-case discussed on this thread: &lt;a href=&quot;http://groups.google.com/group/mongodb-user/browse_thread/thread/b62bea001b9f81ea#&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://groups.google.com/group/mongodb-user/browse_thread/thread/b62bea001b9f81ea#&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The user wants to track the last 10 users to view a given profile - so he needs capped arrays &lt;a href=&quot;http://jira.mongodb.org/browse/SERVER-991&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;http://jira.mongodb.org/browse/SERVER-991&lt;/a&gt; but also need the most recent visitor to always be at the end of the array in a way that $addToSet doesn&apos;t do.&lt;/p&gt;

&lt;p&gt;This interests me because it is also a feature I plan to implement on my web site - very common social networking use-case.&lt;/p&gt;</comment>
                            <comment id="22374" author="keithbranton" created="Sat, 15 Jan 2011 18:47:31 +0000"  >&lt;p&gt;$unshiftToSet would be really useful to me. My application allows users to change the order of lists, usually represented as an array of FKs in mongo. I currently replace the whole document with optimistic locking semantics to achieve this, but I would much rather use modifiers.&lt;/p&gt;

&lt;p&gt;The complication here is concurrent modifications. If user A reads &lt;span class=&quot;error&quot;&gt;&amp;#91;1,2,3,4,5&amp;#93;&lt;/span&gt; and changes it to &lt;span class=&quot;error&quot;&gt;&amp;#91;1,3,5,2,4&amp;#93;&lt;/span&gt; but in the meantime user B has changed the array to &lt;span class=&quot;error&quot;&gt;&amp;#91;7,1,2,6,4,3&amp;#93;&lt;/span&gt;, then I would want the array to look like &lt;span class=&quot;error&quot;&gt;&amp;#91;1,3,5,2,4,7,6&amp;#93;&lt;/span&gt; after user A&apos;s changes are saved.&lt;/p&gt;

&lt;p&gt;With $unshiftToSet I could use an update with {$unshiftToSet:{a:{$each:&lt;span class=&quot;error&quot;&gt;&amp;#91;1,3,5,2,4&amp;#93;&lt;/span&gt;}}} to achieve this. &lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="43910">SERVER-6399</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="14225">SERVER-2363</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="74314">SERVER-9591</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="11839">SERVER-1050</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>10.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25143"><![CDATA[Query]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Sun, 16 Jan 2011 04:55:01 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 32 weeks, 4 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-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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-1021</customfieldvalue>
                        </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>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            4 years, 32 weeks, 4 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>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>backlog-server-query</customfieldvalue>
            <customfieldvalue>benb7760</customfieldvalue>
            <customfieldvalue>chrishanks</customfieldvalue>
            <customfieldvalue>dandv</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>keithbranton</customfieldvalue>
            <customfieldvalue>justanyone</customfieldvalue>
            <customfieldvalue>tpdi</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrp8jz:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6070</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|hs72c7:</customfieldvalue>

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