<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:53:17 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-176] $addToSet | push unique item to array (WAS: Support for set type or set-like operations for arrays )</title>
                <link>https://jira.mongodb.org/browse/SERVER-176</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Might be useful to have a set (unique array) type, or support set-like operations on arrays ($pushUnique). No real specific use case in mind, just something redis supports that seems cool.&lt;/p&gt;</description>
                <environment></environment>
        <key id="10341">SERVER-176</key>
            <summary>$addToSet | push unique item to array (WAS: Support for set type or set-like operations for arrays )</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</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="eliot">Eliot Horowitz</assignee>
                                    <reporter username="mike">Michael Dirolf</reporter>
                        <labels>
                    </labels>
                <created>Wed, 22 Jul 2009 15:29:49 +0000</created>
                <updated>Tue, 12 Jul 2016 00:27:47 +0000</updated>
                            <resolved>Thu, 11 Feb 2010 13:49:37 +0000</resolved>
                                                    <fixVersion>1.3.2</fixVersion>
                                    <component>Write Ops</component>
                                        <votes>14</votes>
                                    <watches>9</watches>
                                                                                                                <comments>
                            <comment id="12257" author="eliot" created="Thu, 11 Feb 2010 13:49:12 +0000"  >&lt;p&gt;going to resolve this since $addToSet works, and added new case for { $addToSet : &lt;/p&gt;
{ $each : [] }
&lt;p&gt; }&lt;/p&gt;</comment>
                            <comment id="11998" author="auto" created="Tue, 26 Jan 2010 17:32:23 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;login&apos;: &apos;erh&apos;, &apos;name&apos;: &apos;Eliot Horowitz&apos;, &apos;email&apos;: &apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: $addToSet mostly working &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-176&quot; title=&quot;$addToSet | push unique item to array (WAS: Support for set type or set-like operations for arrays )&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-176&quot;&gt;&lt;del&gt;SERVER-176&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo/commit/556c5a6d7d0fdf71a3f43960d82d4e0cf723a81b&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo/commit/556c5a6d7d0fdf71a3f43960d82d4e0cf723a81b&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="11995" author="eliot" created="Tue, 26 Jan 2010 17:12:05 +0000"  >&lt;p&gt;decided on the name $addToSet&lt;/p&gt;</comment>
                            <comment id="11992" author="abryan17" created="Tue, 26 Jan 2010 17:05:27 +0000"  >&lt;p&gt;I&apos;m also holding my breath for this feature... it would it easier to combine more operations into a single call.&lt;/p&gt;

&lt;p&gt;For example (perl).. if you had a document with tags (indexed), you could update or create &lt;b&gt;and&lt;/b&gt; add multiple tags (while staying unique) with:&lt;/p&gt;

&lt;p&gt;$coll-&amp;gt;update(&lt;br/&gt;
      &lt;/p&gt;
{ &apos;_id&apos; =&amp;gt; $id }
&lt;p&gt;,&lt;br/&gt;
      {&lt;br/&gt;
        &apos;$set&apos; =&amp;gt; &lt;/p&gt;
{ &apos;foo&apos;  =&amp;gt; $bar  }
&lt;p&gt;,&lt;br/&gt;
        &apos;$pushAllUnique&apos; =&amp;gt; &lt;/p&gt;
{ &apos;tags&apos; =&amp;gt; \@tags }
&lt;p&gt;,&lt;br/&gt;
      },&lt;br/&gt;
      &lt;/p&gt;
{ &apos;upsert&apos; =&amp;gt; 1 }
&lt;p&gt;,&lt;br/&gt;
    );&lt;/p&gt;

&lt;p&gt;Without the $pushAllUnique you&apos;d probably have to do (num new tags + 1) updates...&lt;/p&gt;</comment>
                            <comment id="11833" author="eliot" created="Tue, 19 Jan 2010 17:42:59 +0000"  >&lt;p&gt;just blocking on name.&lt;/p&gt;</comment>
                            <comment id="11550" author="gregglind" created="Tue, 29 Dec 2009 16:20:34 +0000"  >&lt;p&gt;I would also really like set() as a first class type in mongo, for the reasons that Ian White mentioned, for things like $pushAllUnique.&lt;/p&gt;</comment>
                            <comment id="11284" author="eliot" created="Sat, 5 Dec 2009 10:54:06 +0000"  >&lt;p&gt;I understand.  I&apos;m just saying if there is in fact with the current functionality, that should be in its own case.&lt;br/&gt;
You can&apos;t modify _id, so i&apos;m not sure what&apos;s going on yet.&lt;/p&gt;</comment>
                            <comment id="11282" author="erob" created="Sat, 5 Dec 2009 09:00:07 +0000"  >
&lt;p&gt;The comments on this page are linking to this page:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.mongodb.org/display/DOCS/Updating#Updating-%24pushaUniqueValue&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.mongodb.org/display/DOCS/Updating#Updating-%24pushaUniqueValue&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If its belong here or not I don&apos;t know, I just followed a link in hope to find a work-around&lt;br/&gt;
for supporting merge operations. &lt;/p&gt;

&lt;p&gt;Regards, Etienne&lt;/p&gt;</comment>
                            <comment id="11281" author="eliot" created="Fri, 4 Dec 2009 20:26:03 +0000"  >&lt;p&gt;if you can reproduce your error - can you create a new case with the error.  &lt;br/&gt;
doesn&apos;t really belong here.&lt;/p&gt;</comment>
                            <comment id="11280" author="erob" created="Fri, 4 Dec 2009 20:07:29 +0000"  >&lt;p&gt;Yes, i use something like&lt;/p&gt;

&lt;p&gt;&amp;gt; Manager.update(dict(_id=data&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;_id&amp;#39;&amp;#93;&lt;/span&gt;), &lt;/p&gt;
{&quot;$push&quot;: data}
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;pymongo-1.1.1 and mongodb 1.1.3 (using 32bit binaries for linux)&lt;/p&gt;

&lt;p&gt;my use case is a simple yaml file that i want to use as a fixture, to merge&lt;br/&gt;
into a MongoDB collection. i then use the yaml module to convert the file&lt;br/&gt;
into a dict instance, where it contains the new &quot;updated&quot; set. &lt;/p&gt;

&lt;p&gt;Regards,&lt;br/&gt;
Etienne&lt;/p&gt;


</comment>
                            <comment id="11277" author="eliot" created="Fri, 4 Dec 2009 13:11:13 +0000"  >&lt;p&gt;Were you trying to modify _id?&lt;/p&gt;</comment>
                            <comment id="11276" author="erob" created="Fri, 4 Dec 2009 12:18:51 +0000"  >&lt;p&gt;Got this in the logs while attempting the solutions proposed above:&lt;/p&gt;

&lt;p&gt;Fri Dec  4 12:11:13 User Exception Mod on _id not allowed&lt;br/&gt;
Fri Dec  4 12:11:13  test4.movies  Caught Assertion update, continuing&lt;br/&gt;
Fri Dec  4 12:11:13 update test4.movies  query: &lt;/p&gt;
{ _id: &quot;movies2&quot; }
&lt;p&gt; exception userassert:Mod on _id not allowed 0ms&lt;/p&gt;

&lt;p&gt;should it be possible to use $set or $push to &apos;merge&apos; a set with another ?&lt;/p&gt;

&lt;p&gt;Thanks! &lt;br/&gt;
Etienne&lt;/p&gt;</comment>
                            <comment id="11253" author="ibwhite" created="Mon, 30 Nov 2009 19:16:29 +0000"  >&lt;p&gt;Mathias&apos;s solutions are both helpful but neither one is a replacement for a $pushAllUnique, which is what I&apos;d really find useful. (Other set-like operations would be cool, but all I really need is $pushAllUnique, and $pullAll which Mongo already has.)&lt;/p&gt;

&lt;p&gt;The first solution (objects) is problematic because AFAIK you can&apos;t index types in a general way. You can index types.apple, but then you need a different index for each possible type of fruit.&lt;/p&gt;

&lt;p&gt;The second solution is great when you just want to $push one item, but it&apos;s not sufficient if you want to $pushAll multiple items and retain uniqueness. In that case, you have to do multiple updates, which is problematic if you want the update to be atomic.&lt;/p&gt;</comment>
                            <comment id="11174" author="jnunemaker" created="Wed, 18 Nov 2009 00:11:51 +0000"  >&lt;p&gt;Good point. This solves the push unique issue. I can still see merit in other set operations but thanks for posting that.&lt;/p&gt;</comment>
                            <comment id="11173" author="redbeard0531" created="Tue, 17 Nov 2009 23:57:59 +0000"  >&lt;p&gt;Since this was posted to twitter I thought I&apos;d add another way to do this with current mongod:&lt;/p&gt;

&lt;p&gt;update({&quot;_id&quot;=&quot;fruits&quot;, &quot;types&quot;: {&quot;$ne&quot;: &quot;orange&quot;}}, {&quot;$push&quot;: {&quot;types&quot;: &quot;orange&quot;}})&lt;/p&gt;

&lt;p&gt;This should be at least as fast as first-class sets in BSON, at least for smallish sizes.&lt;/p&gt;</comment>
                            <comment id="11172" author="jnunemaker" created="Tue, 17 Nov 2009 21:44:27 +0000"  >&lt;p&gt;Mathias, &lt;br/&gt;
Interesting idea, though the true is really just taking up extra space. I&apos;ve been using arrays and doing checks before adding to the array. It would be awesome to just have a set type and never have to think about if the value is there or not. &lt;/p&gt;

&lt;p&gt;Also, set operations like superset, subset, and intersection could be very cool. &lt;/p&gt;</comment>
                            <comment id="10541" author="redbeard0531" created="Mon, 24 Aug 2009 14:53:26 +0000"  >&lt;p&gt;I use objects for this. For example I might have a document like {&quot;_id&quot;: &quot;friuts&quot;, &quot;types&quot;: {&quot;apple&quot;: true}} then I can use update(&lt;/p&gt;
{&quot;_id&quot;=&quot;fruits&quot;}
&lt;p&gt;, {&quot;$set&quot;: {&quot;types.orange&quot;, true}}) when I need to add to the set. This works with both JSON and JavaScript both of which lack a real set type.&lt;/p&gt;

&lt;p&gt;Rather than add a set type it may make sense to optimize this case (if you aren&apos;t already)&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="11289">SERVER-628</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>17.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 24 Aug 2009 14:53:26 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        14 years, 1 week, 6 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>
                            14 years, 1 week, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>abryan17</customfieldvalue>
            <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>erob</customfieldvalue>
            <customfieldvalue>gregglind</customfieldvalue>
            <customfieldvalue>ibwhite</customfieldvalue>
            <customfieldvalue>jnunemaker</customfieldvalue>
            <customfieldvalue>mathias@mongodb.com</customfieldvalue>
            <customfieldvalue>mike</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrpx93:</customfieldvalue>

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

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

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