<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:17:38 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-8512] support $slice/sort in $addToSet</title>
                <link>https://jira.mongodb.org/browse/SERVER-8512</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-991&quot; title=&quot;$push with $slice + $sort&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-991&quot;&gt;&lt;del&gt;SERVER-991&lt;/del&gt;&lt;/a&gt; is about adding $slice to $push, but &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=scotthernandez&quot; class=&quot;user-hover&quot; rel=&quot;scotthernandez&quot;&gt;scotthernandez&lt;/a&gt; says it should also be supported for $addToSet (or throw an error).&lt;/p&gt;</description>
                <environment></environment>
        <key id="64889">SERVER-8512</key>
            <summary>support $slice/sort in $addToSet</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="derick">Derick Rethans</reporter>
                        <labels>
                            <label>operations</label>
                    </labels>
                <created>Mon, 11 Feb 2013 20:35:18 +0000</created>
                <updated>Fri, 6 Nov 2015 17:09:37 +0000</updated>
                            <resolved>Tue, 12 Feb 2013 02:14:20 +0000</resolved>
                                    <version>2.4.0-rc0</version>
                                                                        <votes>0</votes>
                                    <watches>11</watches>
                                                                                                                <comments>
                            <comment id="1081902" author="waldgeist" created="Fri, 6 Nov 2015 17:09:37 +0000"  >&lt;p&gt;I ran in the same problem, and the reason for closing this request is quite unlogical to me.&lt;/p&gt;

&lt;p&gt;My use case: I want to store a list of subjects a user is familar with. This should be a unique, sorted list of strings. If $addToSet is only meant for sets, how else can one prevent to add an already existing array element twice &lt;b&gt;and&lt;/b&gt; maintain sort order at the same time? It does not make any sense to me to do this in two subsequent updates.&lt;/p&gt;</comment>
                            <comment id="1081324" author="pdiniz" created="Fri, 6 Nov 2015 00:34:54 +0000"  >&lt;p&gt;I agree with Guillaume Gelin. Specially once you add support for $each to $addToSet it seems like a simple step to be able to add a sort. Im trying to maintain a sorted ordered list, and currently the only way to do that is to first add the elements with $addToSet and then sort them with an empty $push. If $addToSet is meant to be used only for sets it shouldnt be under the array section and have this &quot;The $addToSet operator adds a value to an array unless the value is already present, in which case $addToSet does nothing to that array.&quot; as it&apos;s description.&lt;/p&gt;</comment>
                            <comment id="755566" author="ramnes" created="Tue, 4 Nov 2014 13:30:24 +0000"  >&lt;p&gt;Sorry to put this back up, but those differences between $push and $addToSet look really inconsistent to me.&lt;/p&gt;

&lt;p&gt;My scenario is the following:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;I have a collection in which documents have one field which is an array of integers;&lt;/li&gt;
	&lt;li&gt;I want to add values to those arrays as fast as possible, without fetching any document, and in one atomic operation;&lt;/li&gt;
	&lt;li&gt;I don&apos;t want to push the integer in the array if it&apos;s already in, and I want the array to have a maximum size.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;It seems to me that a fairly logical way of doing this would be {$addToSet: {&quot;v&quot;: {$each: &lt;span class=&quot;error&quot;&gt;&amp;#91;value&amp;#93;&lt;/span&gt;, $slice: size}}}. Actually, I don&apos;t see any way to do this at the moment.&lt;/p&gt;

&lt;p&gt;Edit: obviously, that would suppose that $addToSet could handle inclusion order, and I understand the problem in terms. Maybe it could be done in a new array modifier, or as a new $push modifier.&lt;/p&gt;</comment>
                            <comment id="264113" author="scotthernandez" created="Tue, 12 Feb 2013 15:18:41 +0000"  >&lt;p&gt;Okay, we need to change the docs to make that clear and error out if there are invalide $fields in the modifiers/selectors.&lt;/p&gt;</comment>
                            <comment id="264099" author="eliot" created="Tue, 12 Feb 2013 15:05:33 +0000"  >&lt;p&gt;I don&apos;t want to guarantee that $addToSet puts new items on the end, or can maintain order in anyway.&lt;br/&gt;
I think long term we&apos;ll want it to actually be a set, not an array, so dont&apos; want any more array ops on it.&lt;/p&gt;</comment>
                            <comment id="264097" author="scotthernandez" created="Tue, 12 Feb 2013 15:01:23 +0000"  >&lt;p&gt;All array modifiers should work the same. If you can $push with some selectors then $addToSet should work the same.&lt;/p&gt;

&lt;p&gt;It may very be that the user wants the set sorted, and order is maintained in arrays, so using the new $slice/sort selectors make sense here as well.&lt;/p&gt;</comment>
                            <comment id="263726" author="eliot" created="Tue, 12 Feb 2013 02:14:21 +0000"  >&lt;p&gt;sets are unordered, so don&apos;t think this makes sense.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="64978">DOCS-1114</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="64982">SERVER-8526</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>7.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 12 Feb 2013 02:14:21 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        8 years, 14 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>waldgeist</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            8 years, 14 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>derick</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>ramnes</customfieldvalue>
            <customfieldvalue>pdiniz</customfieldvalue>
            <customfieldvalue>scotthernandez</customfieldvalue>
            <customfieldvalue>waldgeist</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrn7g7:</customfieldvalue>

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

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

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