<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:35:41 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>[CSHARP-57] As a developper, I want to be able to specify the &quot;upsert&quot; option of the FindAndModify command</title>
                <link>https://jira.mongodb.org/browse/CSHARP-57</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I am implementing some kind of serial identifier (simple incrementing counter) functionality as part of a WCF service hosted in IIS. I want to store the counters in a Mongo collection. &lt;/p&gt;

&lt;p&gt;I use the IMongoCollection.FindAndModify with a Mo.Inc(...) document successfully when the document already exists in the collection. However, the first time my &quot;UserFriendlyUniqueIdGenerator&quot; service is accessed, the document doesn&apos;t exist, and I can&apos;t just check for existence and create it if it doesn&apos;t exist because that must be done atomically (race condition). &lt;/p&gt;

&lt;p&gt;I found out in the MondoDB documentation that it is possible to specify an &quot;upsert&quot; option to the FindAndModify command. (&lt;a href=&quot;http://www.mongodb.org/display/DOCS/findandmodify+Command&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.mongodb.org/display/DOCS/findandmodify+Command&lt;/a&gt; and &lt;a href=&quot;http://github.com/mongodb/mongo/blob/master/jstests/find_and_modify4.js&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo/blob/master/jstests/find_and_modify4.js&lt;/a&gt;) I looked at the mongodb-csharp code and this option is not exposed. &lt;/p&gt;

&lt;p&gt;I think I can build and call the command myself and extract the result, but it would be nice if this option could be exposed by the driver in a future version. That would allow to create or increment a counter atomically. &lt;/p&gt;

&lt;p&gt;Discussion thread: &lt;a href=&quot;http://groups.google.com/group/mongodb-csharp/browse_thread/thread/69b1378665ea8f76/522c2cd49ec7b3af#522c2cd49ec7b3af&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://groups.google.com/group/mongodb-csharp/browse_thread/thread/69b1378665ea8f76/522c2cd49ec7b3af#522c2cd49ec7b3af&lt;/a&gt;&lt;/p&gt;</description>
                <environment>Driver samus-mongodb-csharp-85d3524&lt;br/&gt;
MongoDB 1.6</environment>
        <key id="12825">CSHARP-57</key>
            <summary>As a developper, I want to be able to specify the &quot;upsert&quot; option of the FindAndModify command</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="lanwin">Steve Wagner</assignee>
                                    <reporter username="gduford">Gabriel Duford</reporter>
                        <labels>
                    </labels>
                <created>Wed, 18 Aug 2010 17:34:10 +0000</created>
                <updated>Wed, 19 Oct 2016 14:16:06 +0000</updated>
                            <resolved>Mon, 6 Sep 2010 14:48:18 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="17823" author="lanwin" created="Mon, 6 Sep 2010 14:48:18 +0000"  >&lt;p&gt;Fixed in my branch &lt;a href=&quot;http://github.com/lanwin/mongodb-csharp&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/lanwin/mongodb-csharp&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <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|hrh9y7:</customfieldvalue>

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