<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:39:59 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-1560] Expose db.collection.save() as SaveAsync on Collection</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1560</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Previous (Legacy) versions of the driver included a .Save() method on the collection that would either insert a new record or update an existing (if _id matched).  Mongo itself has a collection.save() method that should be exposed for those of us who made previous heavy use of Save()&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://docs.mongodb.org/manual/reference/method/db.collection.save/#db.collection.save&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://docs.mongodb.org/manual/reference/method/db.collection.save/#db.collection.save&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="264896">CSHARP-1560</key>
            <summary>Expose db.collection.save() as SaveAsync on Collection</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="sallgeud">Chad Kreimendahl</reporter>
                        <labels>
                    </labels>
                <created>Thu, 11 Feb 2016 21:16:21 +0000</created>
                <updated>Mon, 11 Mar 2019 19:22:06 +0000</updated>
                            <resolved>Mon, 11 Mar 2019 19:22:06 +0000</resolved>
                                    <version>2.2.3</version>
                                                    <component>Operations</component>
                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="2177554" author="ian@10gen.com" created="Mon, 11 Mar 2019 19:22:06 +0000"  >&lt;p&gt;Closing as Won&apos;t Fix - after discussion within the Drivers team we&apos;ve decided not to pursue such a method for now.&lt;/p&gt;</comment>
                            <comment id="1236473" author="craiggwilson" created="Thu, 14 Apr 2016 21:56:55 +0000"  >&lt;p&gt;Thanks Chad.&lt;/p&gt;

&lt;p&gt;I&apos;m glad that is working for you. I&apos;ll ping you guys back if we come to the conclusion that this should be part of the drivers.&lt;/p&gt;

&lt;p&gt;Craig&lt;/p&gt;</comment>
                            <comment id="1236025" author="sallgeud" created="Thu, 14 Apr 2016 16:34:38 +0000"  >&lt;p&gt;So the issue, when comparing old Save functionality to new functionality is that there is currently no good way to send an &quot;_id&quot;-less document for upsert (replaceone w/ upsert), and have it return the new Id.  The Legacy .Save method does this very well.&lt;/p&gt;

&lt;p&gt;It would be great, instead of building my own IMongoCollection&amp;lt;object&amp;gt; static extensions, if we could get a sync and async method to perform these steps for us in the new code. &lt;/p&gt;

&lt;p&gt;Basically we want to take an object that may or may not have an _id assigned, and we want to either create (no _id) or upsert (has _id). If the object did not have an id prior, set it, so we can reuse it post-save.&lt;/p&gt;

&lt;p&gt;For now, I&apos;ve basically copied the code from your Save method in Legacy, and rewritten the Insert and Update to be InsertOneAsync and ReplaceOneAsync, with some minor tweaks.&lt;/p&gt;

&lt;p&gt;I could get one of my team to possibly contribute what we&apos;ve done back into a pull request, if this is something useful beyond just us.&lt;/p&gt;</comment>
                            <comment id="1215452" author="sallgeud" created="Fri, 25 Mar 2016 17:40:55 +0000"  >&lt;p&gt;Thanks... That makes sense. &lt;/p&gt;</comment>
                            <comment id="1215386" author="craiggwilson" created="Fri, 25 Mar 2016 16:42:29 +0000"  >&lt;p&gt;Good question. I should have given an explanation.&lt;/p&gt;

&lt;p&gt;It is in the shell for backward compatibility and it is in the .NET driver&apos;s legacy API. However, none of our drivers have implemented &quot;save&quot; in their most recent major versions. Each driver follows the &lt;a href=&quot;https://github.com/mongodb/specifications/tree/master/source&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;CRUD specification&lt;/a&gt; and we try very hard not to introduce methods that are not across all drivers. In this case, we&apos;d need to have a majority of drivers add the method for consistency, which is why it&apos;s undecided.&lt;/p&gt;

&lt;p&gt;We have had long discussions about this very method and thus far have decided to not add them to our drivers. In a vast majority of cases, a user will know whether or not the document is new or needs to be updated. In the case where you don&apos;t, replaceOne will generally suffice with it&apos;s upsert flag set to true.&lt;/p&gt;
</comment>
                            <comment id="1215376" author="sallgeud" created="Fri, 25 Mar 2016 16:33:21 +0000"  >&lt;p&gt;Given that this command exists within mongo itself... why would implementing it remain undecided?&lt;/p&gt;</comment>
                            <comment id="1171289" author="sallgeud" created="Thu, 11 Feb 2016 23:20:51 +0000"  >&lt;p&gt;If it helps, we&apos;d consider doing this and sending a pull request.  I presume simply wiring up the same functionality that exists in the legacy would be acceptable to most... &lt;/p&gt;

&lt;p&gt;That means accepting a document, if it doesn&apos;t have an ID, use the serializers&apos; idgenerator, if it does have an id, use update/upsert.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="199580">CSHARP-1249</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|hsmecn:</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>