<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:55:29 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>[JAVA-1782] Document that eval is deprecated in 3.0</title>
                <link>https://jira.mongodb.org/browse/JAVA-1782</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Based on &lt;a href=&quot;http://docs.mongodb.org/manual/reference/command/eval/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://docs.mongodb.org/manual/reference/command/eval/&lt;/a&gt; and &lt;a href=&quot;http://docs.mongodb.org/manual/reference/method/db.eval/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://docs.mongodb.org/manual/reference/method/db.eval/&lt;/a&gt;, eval is deprecated in 3.0.&lt;/p&gt;

&lt;p&gt;DB#eval and DB#doEval should be marked as deprecated. Also, I would really appreciate comments suggesting what to use instead of eval.&lt;/p&gt;

&lt;p&gt;To quote the existing comments: eval &quot;Evaluates JavaScript functions on the database server. This is useful if you need to touch a lot of data lightly, in which case network transfer could be a bottleneck.&quot;&lt;/p&gt;

&lt;p&gt;What is a good alternative to this?&lt;/p&gt;</description>
                <environment></environment>
        <key id="200701">JAVA-1782</key>
            <summary>Document that eval is deprecated in 3.0</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="-1">Unassigned</assignee>
                                    <reporter username="willchan83">William Chan</reporter>
                        <labels>
                            <label>documentation</label>
                    </labels>
                <created>Tue, 28 Apr 2015 07:32:13 +0000</created>
                <updated>Mon, 24 Aug 2015 09:43:42 +0000</updated>
                            <resolved>Tue, 28 Apr 2015 09:03:51 +0000</resolved>
                                    <version>3.0.0</version>
                                                    <component>Documentation</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="899629" author="ross@10gen.com" created="Tue, 28 Apr 2015 09:13:55 +0000"  >&lt;p&gt;Added a &lt;a href=&quot;https://jira.mongodb.org/browse/DRIVERS-225&quot; title=&quot;Deprecate eval helpers&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DRIVERS-225&quot;&gt;&lt;del&gt;DRIVERS-225&lt;/del&gt;&lt;/a&gt; for other drivers to ensure they deprecate any &lt;tt&gt;$eval&lt;/tt&gt; command helpers.&lt;/p&gt;</comment>
                            <comment id="899624" author="ross@10gen.com" created="Tue, 28 Apr 2015 09:03:51 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=willchan83&quot; class=&quot;user-hover&quot; rel=&quot;willchan83&quot;&gt;willchan83&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;In 3.0.0 &lt;tt&gt;MongoClient.getDB()&lt;/tt&gt; was deprecated meaning that all code under &lt;tt&gt;DB&lt;/tt&gt; has been deprecated - including &lt;tt&gt;DB#eval&lt;/tt&gt; and &lt;tt&gt;DB#doEval&lt;/tt&gt;.  We haven&apos;t added a &lt;tt&gt;eval&lt;/tt&gt; helper in &lt;tt&gt;MongoDatabase&lt;/tt&gt; (the &lt;tt&gt;DB&lt;/tt&gt; replacement) but there is the &lt;tt&gt;runCommand&lt;/tt&gt; helper for running arbitrary commands.&lt;/p&gt;

&lt;p&gt;The &lt;tt&gt;eval&lt;/tt&gt; command was deprecated in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-17453&quot; title=&quot;warn that db.eval() / eval command is deprecated&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-17453&quot;&gt;&lt;del&gt;SERVER-17453&lt;/del&gt;&lt;/a&gt; and was documented in &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-4899&quot; title=&quot;document eval is deprecated&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-4899&quot;&gt;&lt;del&gt;DOCS-4899&lt;/del&gt;&lt;/a&gt;.  The reasons for the decision are mentioned in the SERVER ticket:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;There are a number of issues with the eval command.&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Compatibility: eval was developed before the introduction of sharding. The eval command does not work on sharded clusters at all.&lt;/li&gt;
	&lt;li&gt;Performance: Takes a global lock by default.  If eval is with the &lt;tt&gt;noLock&lt;/tt&gt; option, it implies that the javascript could just as easily be run from a client program.&lt;/li&gt;
	&lt;li&gt;Security: You must have access to all actions on all resources in order to run eval.  Security best practices depend on being able to segment privileges to actions, and eval gives too broad a range of powers.&lt;/li&gt;
	&lt;li&gt;Maintenance: The server must move to a model where javascript is executed &quot;out of process&quot; for a number of reasons; maintaining support for eval makes this very difficult.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is no alternative from a driver perspective other than coding the functionality from the driver.  However, you still can use the shell directly, which is a javascript runtime.&lt;/p&gt;

&lt;p&gt;I hope that answers your question and as there is no work to be done I&apos;m going to close this ticket &quot;Works as Designed&quot;.  &lt;/p&gt;

&lt;p&gt;For future reference, the best place for general questions regarding MongoDB usage or the Java driver specifics is the &lt;a href=&quot;https://groups.google.com/forum/#!forum/mongodb-user&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;mongodb-user mailinglist&lt;/a&gt; or &lt;a href=&quot;http://stackoverflow.com&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;stackoverflow&lt;/a&gt; as you will reach a boarder audience there.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="200712">DRIVERS-225</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hs8tsn:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>