<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:04:57 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-4102] Add $nop operation to modifier</title>
                <link>https://jira.mongodb.org/browse/SERVER-4102</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Although it can be worked around, it can be problematic that when an empty modifier object is used with findAndModify it removes all properties of the document. We suggest adding a no-op modifier operation, $nop, which makes no change to the document. This can therefore be added to all modifier operations and will ensure that previously empty ones will not wipe out the document:&lt;/p&gt;

&lt;p&gt;Usage:&lt;br/&gt;
{ $nop: {} }&lt;/p&gt;</description>
                <environment></environment>
        <key id="23835">SERVER-4102</key>
            <summary>Add $nop operation to modifier</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="-1">Unassigned</assignee>
                                    <reporter username="richardms">Richard Miller-Smith</reporter>
                        <labels>
                            <label>update</label>
                    </labels>
                <created>Wed, 19 Oct 2011 21:05:19 +0000</created>
                <updated>Fri, 7 Mar 2014 00:21:25 +0000</updated>
                            <resolved>Thu, 20 Oct 2011 09:04:00 +0000</resolved>
                                                                    <component>Usability</component>
                    <component>Write Ops</component>
                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="61569" author="scotthernandez" created="Thu, 20 Oct 2011 09:03:44 +0000"  >&lt;p&gt;In many drivers there is a findOne which takes a field restriction and a sort. This is really not an issue for the server but one of your client (driver). Please file an issue with the node.js driver if you want a findOne method which takes those parameters, assuming there isn&apos;t one, which would actually surprise me...&lt;/p&gt;

&lt;p&gt;findOne is shorthand for this:&lt;/p&gt;

&lt;p&gt;findOne(args):&lt;br/&gt;
var cursor = find(args).limit(1)&lt;br/&gt;
if (cursor.hasNext())&lt;br/&gt;
  return cursor.next()&lt;br/&gt;
else&lt;br/&gt;
  return null;&lt;/p&gt;

&lt;p&gt;The same behavior exists for update.&lt;/p&gt;

&lt;p&gt;I would suggest filing a bug for findAndModify with an empty set of updateOperations not generating an error but really, that again should be checked by the driver before it ever sends it to the server.&lt;/p&gt;</comment>
                            <comment id="61567" author="richardms" created="Thu, 20 Oct 2011 08:43:31 +0000"  >&lt;p&gt;The problem with using findOne() is that it is a much less powerful beast than findAndModify, you can&apos;t give it a fields parameter nor a sort order (let alone options like &apos;upsert&apos;). This means that doing this:&lt;/p&gt;

&lt;p&gt;var result1, 2 ;&lt;br/&gt;
result1 = findAndModify(col, {query:&lt;/p&gt;
{aProperty: &quot;aValue&quot;}
&lt;p&gt;, sort:[&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;aProperty&amp;quot;,1&amp;#93;&lt;/span&gt;], update: &lt;/p&gt;
{something: &quot;toSet&quot;}
&lt;p&gt;, fields: &lt;/p&gt;
{aProperty: 1}
&lt;p&gt;)&lt;br/&gt;
result2 = findOne(col, &lt;/p&gt;
{aProperty: &quot;aValue&quot;}
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;then result1 and result2 could be completely different documents, and at the very least would have different fields. Therefore, you can&apos;t use findOne() as a safe replacement for findAndModify.&lt;/p&gt;

&lt;p&gt;My biggest concern, spurred on by the bugs we have had, is that when you get it wrong and accidently call findAndModify with an empty object it does such a dangerous thing - wiping out the object. Which basically means that anywhere a modifier is created (that could possibly be empty) then you cannot just use findAndModify, you have to remember to use an arrangement at least as complex as yours above.&lt;/p&gt;

&lt;p&gt;Perhaps a $nop isn&apos;t the best solution - maybe just another option to findAndModify would fix it. But I do think this is a real issue that bites and surprises people when they suddenly discover objects have been wiped out, and it seems strange to have such a powerful call as findAndModify and then need to wrap it with extra code in order to catch corner cases. &lt;/p&gt;</comment>
                            <comment id="61516" author="scotthernandez" created="Wed, 19 Oct 2011 21:51:23 +0000"  >&lt;p&gt;I still don&apos;t get the issue, or need.&lt;/p&gt;

&lt;p&gt;Here is the logic in psudocode:&lt;/p&gt;

&lt;p&gt;var mods = ...&lt;br/&gt;
var result;&lt;br/&gt;
if (mods is empty) result = findOne&lt;br/&gt;
else result = findAndModify&lt;/p&gt;

&lt;p&gt;If you have no mods, don&apos;t do a findAndModify.&lt;/p&gt;

&lt;p&gt;I don&apos;t understand what this has to do with sorting, or two calls.&lt;/p&gt;</comment>
                            <comment id="61514" author="richardms" created="Wed, 19 Oct 2011 21:34:29 +0000"  >&lt;p&gt;Indeed, and that is what we are currently doing. However, as we are using JavaScript (in node.js) in order to get the correct object back (due to sorting etc) we have to do two async calls instead of one: a find() and then read the first item from the cursor. It was just a thought that having a mechanism (such as this) that could mark a modifier as a no-op would make usage a bit easier - this problem has reared its head a few times now on our project.&lt;/p&gt;</comment>
                            <comment id="61508" author="scotthernandez" created="Wed, 19 Oct 2011 21:11:44 +0000"  >&lt;p&gt;If you don&apos;t need to modify the document, just do a query.&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>5.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 19 Oct 2011 21:11:44 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        12 years, 17 weeks, 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>ian@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            12 years, 17 weeks, 6 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>richardms</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|hronqn:</customfieldvalue>

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

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

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