<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:53:07 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-130] array $pull operator</title>
                <link>https://jira.mongodb.org/browse/SERVER-130</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I believe adding a $pull modifier - the opposite of $push - would be a&lt;br/&gt;
powerful addition to the MongoDB features.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;db.group.insert({_id:1,text:&apos;user group 1&apos;,users:&lt;span class=&quot;error&quot;&gt;&amp;#91;1,2,3&amp;#93;&lt;/span&gt;});&lt;/p&gt;

&lt;p&gt;// add another user - atomic&lt;br/&gt;
db.blogs.update({_id:1},{ $push : &lt;/p&gt;
{ users : 4 }
&lt;p&gt; } );&lt;/p&gt;

&lt;p&gt;// remove a user - atomic&lt;br/&gt;
db.blogs.update({_id:1},{ $pull : &lt;/p&gt;
{ users : 2 }
&lt;p&gt; });&lt;/p&gt;</description>
                <environment></environment>
        <key id="10258">SERVER-130</key>
            <summary>array $pull operator</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="aaron">Aaron Staple</assignee>
                                    <reporter username="eliot">Eliot Horowitz</reporter>
                        <labels>
                    </labels>
                <created>Mon, 6 Jul 2009 21:27:37 +0000</created>
                <updated>Tue, 12 Jul 2016 00:29:58 +0000</updated>
                            <resolved>Wed, 22 Jul 2009 17:36:00 +0000</resolved>
                                                    <fixVersion>0.9.7</fixVersion>
                                    <component>Usability</component>
                                        <votes>4</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="432228" author="ivan123" created="Fri, 27 Sep 2013 02:57:05 +0000"  >&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;@sandstrom:&lt;br/&gt;
&quot;I agree with Wouter. No need to return the pulled item. I really dislike how PHP&apos;s pop returns the popped value, it&apos;s completely useless.&quot;&lt;/p&gt;

&lt;p&gt;I found a case where this is not true. I&apos;m storing some aggregated values (like averages) from certain fields of the array&apos;s elements in the containing document (for performance). When I remove an element from the array, I have to recalculate the aggregated values. In this case it&apos;s useful if I get the removed element. Otherwise I have to do 2 queries (retrieve the element and pull).&lt;/p&gt;

&lt;p&gt;Besides of that I also could imagine cases where at point of deleting an item, only the id is known. After delete I want to send a confirmation to the user about the deleted item, maybe with name or something. It would be easy if pull returned the removed element, otherwise again 2nd query is necessary.&lt;/p&gt;

&lt;p&gt;This is written a few years later but right now I&apos;m missing this functionality. Wonder why nobody else has mentioned this.&lt;/p&gt;</comment>
                            <comment id="10328" author="aaron" created="Tue, 28 Jul 2009 14:50:26 +0000"  >&lt;p&gt;Hi Wouter,&lt;/p&gt;

&lt;p&gt;I wrote $pull to remove all matching elements because arrays are often used to store sets of values, and set logic is used when matching an array. You&apos;re the one with a use case though, so let us know what functionality makes the most sense for you. Do you also want a &apos;pop&apos; modifier that doesn&apos;t accept a value argument?&lt;/p&gt;

&lt;p&gt;Aaron&lt;/p&gt;</comment>
                            <comment id="10317" author="wouter" created="Fri, 24 Jul 2009 14:49:41 +0000"  >&lt;p&gt;What is the expected behaviour of $pull?!&lt;/p&gt;

&lt;p&gt;Now, if the array contains a value several times, all of them are removed if you run $pull.&lt;/p&gt;

&lt;p&gt;{_id:1,arr : &lt;span class=&quot;error&quot;&gt;&amp;#91;1,2,2,2&amp;#93;&lt;/span&gt;}&lt;/p&gt;

&lt;p&gt;update({_id:1},{$pull:{arr:2}});&lt;/p&gt;

&lt;p&gt;{_id:1,arr : &lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;}&lt;/p&gt;

&lt;p&gt;Not sure if this is good or bad - just wanted to let this know.&lt;/p&gt;

&lt;p&gt;BTW array_pop is different, array_pop is run on the array, you don&apos;t specify the value you want to be removed, so it&apos;s a good thing the removed value is returned (Compare: $removed_item = array_pop($array); vs $pull : &lt;/p&gt;
{ array_name : $removed_item }
&lt;p&gt;)&lt;/p&gt;</comment>
                            <comment id="10310" author="aaron" created="Wed, 22 Jul 2009 17:36:00 +0000"  >&lt;p&gt;Ok, I&apos;ve gone ahead and implemented $pull, tested in pull.js.  Let me know if you have any difficulties.&lt;/p&gt;</comment>
                            <comment id="10286" author="sandstrom" created="Mon, 20 Jul 2009 07:52:08 +0000"  >&lt;p&gt;I agree with Wouter. No need to return the pulled item. I really dislike how PHP&apos;s pop returns the popped value, it&apos;s completely useless.&lt;br/&gt;
Better to return this (or equivalent) for chaining, or nothing at all (throwing an error if it fails).&lt;/p&gt;

&lt;p&gt;Since virtual collections will eliminate the need for push/pull it might be better to spend the time on implementing them. &lt;a href=&quot;http://jira.mongodb.org/browse/SERVER-142&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;http://jira.mongodb.org/browse/SERVER-142&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="10231" author="wouter" created="Tue, 7 Jul 2009 16:58:59 +0000"  >&lt;p&gt;@Dwight:&lt;/p&gt;

&lt;p&gt;Well, you specify the value(s) that you want to remove from the array. If you want to know what values are actually in the array, you can simply read the object.&lt;/p&gt;

&lt;p&gt;If I run &lt;br/&gt;
db.group.update({_id:1},{ $pull : &lt;/p&gt;
{ users : 2 }
&lt;p&gt; });&lt;/p&gt;

&lt;p&gt;I do not need to know if the value &apos;2&apos; was in the array. I just want to be sure it is not in the array after the update &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="10226" author="dwight_10gen" created="Mon, 6 Jul 2009 21:36:26 +0000"  >&lt;p&gt;seems to me oine would want the popped (pulled) item returned.  not sure best way to do that.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 6 Jul 2009 21:36:26 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        10 years, 20 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></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>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            10 years, 20 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>aaron</customfieldvalue>
            <customfieldvalue>dwight@mongodb.com</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>ivan123</customfieldvalue>
            <customfieldvalue>sandstrom</customfieldvalue>
            <customfieldvalue>wouter</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrpxp3:</customfieldvalue>

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

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

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