<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:04:14 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>[DOCS-12034] Add code examples to Swift SDK README</title>
                <link>https://jira.mongodb.org/browse/DOCS-12034</link>
                <project id="10380" key="DOCS">Documentation</project>
                    <description>&lt;h2&gt;&lt;a name=&quot;Description&quot;&gt;&lt;/a&gt;Description&lt;/h2&gt;
&lt;p&gt;As we discussed on Slack I&apos;m just sending some sample code to potentially add to the GitHub readme for the swift sdk. The physical docs don&apos;t have examples, so I&apos;m not sure if it is worth it to have some of the pages with example code and others without. However, some of this could certainly be added to the README.md to provide a few more complicated examples / walk through how to set it up in the project. &lt;/p&gt;

&lt;p&gt;At the top of every file put: &lt;br/&gt;
import StitchCore&lt;br/&gt;
import StitchRemoteMongoDBService&lt;br/&gt;
(Do not think we need MongoSwiftMobile quite yet)&lt;/p&gt;

&lt;p&gt;1. Inside of AppDelegate.swift: &lt;/p&gt;

&lt;p&gt;func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: &lt;span class=&quot;error&quot;&gt;&amp;#91;UIApplicationLaunchOptionsKey: Any&amp;#93;&lt;/span&gt;?) -&amp;gt; Bool {&lt;br/&gt;
 	do &lt;/p&gt;
{
     	stitchClient = try Stitch.initializeAppClient(withClientAppID: &quot;stitch_appid&quot;)
 	}
&lt;p&gt; catch &lt;/p&gt;
{
     	print(&quot;Unable to connect to stitch client&quot;)
 	}
&lt;p&gt; 	return true&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;2. To Login With Anonymous Credentials: &lt;/p&gt;

&lt;p&gt;stitchClient.auth.login(withCredential: AnonymousCredential()) {result in&lt;br/&gt;
    switch result {&lt;br/&gt;
    case .success(_):&lt;br/&gt;
        print(&quot;Stitch User ID: &quot; + stitchClient.auth.currentUser!.id)&lt;br/&gt;
        DispatchQueue.main.async &lt;/p&gt;
{
           // update UI accordingly
       }
&lt;p&gt;    case .failure(let error):&lt;br/&gt;
        print(&quot;failed logging in Stitch with Facebook. error: &amp;#40;error)&quot;)&lt;br/&gt;
    }&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;3. To Login with another Credential (Facebook):&lt;/p&gt;

&lt;p&gt;// At The top of the page&lt;br/&gt;
import FacebookLogin&lt;br/&gt;
import FBSDKLoginKit &lt;br/&gt;
import StitchCore&lt;/p&gt;

&lt;p&gt;// In viewDidLoad() &lt;br/&gt;
let loginButton = LoginButton(readPermissions: [ .publicProfile, .email, .userFriends ])&lt;br/&gt;
loginButton.center = view.center&lt;br/&gt;
view.addSubview(loginButton)&lt;/p&gt;

&lt;p&gt;// In viewWillAppear() --&amp;gt; will call after Facebook successfully logs in&lt;br/&gt;
if let accessToken = FBSDKAccessToken.current() {&lt;br/&gt;
	let credential = FacebookCredential.init(withAccessToken: accessToken.tokenString)&lt;br/&gt;
	stitchClient.auth.login(withCredential: credential) {result in&lt;br/&gt;
	    switch result {&lt;br/&gt;
	    case .success(_):&lt;br/&gt;
	        print(&quot;Stitch User ID: &quot; + stitchClient.auth.currentUser!.id)&lt;br/&gt;
	        DispatchQueue.main.async &lt;/p&gt;
{
               // update UI accordingly
           }
&lt;p&gt;	    case .failure(let error):&lt;br/&gt;
	        print(&quot;failed logging in Stitch with Facebook. error: &amp;#40;error)&quot;)&lt;br/&gt;
	    }&lt;br/&gt;
	}&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;4. Throughout the rest of the application, to get access to the defaultStitchClient just call: &lt;/p&gt;

&lt;p&gt;private lazy var stitchClient = Stitch.defaultAppClient!&lt;/p&gt;

&lt;p&gt;5. To Perform a Find: &lt;/p&gt;

&lt;p&gt;mongoClient = stitchClient.serviceClient(fromFactory: remoteMongoClientFactory, withName: &quot;mongodb-atlas&quot;)&lt;br/&gt;
collection = mongoClient?.db(&quot;db_name&quot;).collection(&quot;collection_name&quot;)&lt;br/&gt;
collection.find(&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;filter_key&amp;quot;: &amp;quot;filter_value&amp;quot;&amp;#93;&lt;/span&gt;, options: RemoteFindOptions(limit: 3, sort: &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;title&amp;quot;: 1&amp;#93;&lt;/span&gt;)).asArray({ result in&lt;br/&gt;
    switch result {&lt;br/&gt;
    case .success(let result):&lt;br/&gt;
        results.forEach({ document in&lt;br/&gt;
        	guard let arr_of_sub_docs = doc&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;arrDocs&amp;quot;&amp;#93;&lt;/span&gt; as? &lt;span class=&quot;error&quot;&gt;&amp;#91;Document&amp;#93;&lt;/span&gt; else &lt;/p&gt;
{
	            print(&quot;Error: no array of subdocuments found&quot;)
	            exit(0)
        	}
&lt;p&gt;        	print(arr_of_sub_docs&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;subdoc_field&amp;quot;&amp;#93;&lt;/span&gt;)&lt;br/&gt;
        })&lt;/p&gt;

&lt;p&gt;    case .failure(let error):&lt;br/&gt;
        print(&quot;Error in finding documents: &amp;#40;error)&quot;)&lt;br/&gt;
    }&lt;br/&gt;
})&lt;/p&gt;

&lt;p&gt;6. Perform a Function Call: &lt;/p&gt;

&lt;p&gt;stitchClient.callFunction(withName: &quot;insertFunctionName&quot;, withArgs: &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;args&amp;quot;&amp;#93;&lt;/span&gt;, withRequestTimeout: 5.0)&lt;br/&gt;
{(result: StitchResult&amp;lt;String&amp;gt;) in&lt;br/&gt;
    switch result &lt;/p&gt;
{
    case .success(let stringResult):
        print(&quot;String result: \(stringResult)&quot;)
    case .failure(let error):
        print(&quot;Error retrieving String: \(String(describing: error))&quot;)
    }
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;7. Insert a Document &lt;/p&gt;

&lt;p&gt;var newDoc = Document()&lt;br/&gt;
newDoc&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;name&amp;quot;&amp;#93;&lt;/span&gt; 			= stitchClient.auth.currentUser?.profile.name! as! String&lt;br/&gt;
newdoc&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;user_id&amp;quot;&amp;#93;&lt;/span&gt; 		= stitchClient.auth.currentUser!.id&lt;br/&gt;
itemDoc&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;title&amp;quot;&amp;#93;&lt;/span&gt;		= &quot;newDocTitle&quot;&lt;br/&gt;
itemDoc&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;arrOfSubDocs&amp;quot;&amp;#93;&lt;/span&gt; = []&lt;br/&gt;
self.groupCollection?.insertOne(itemDoc, {result in&lt;br/&gt;
    switch result &lt;/p&gt;
{
    case .success(_):
        // Do Something
    case .failure(let error):
        print(&quot;failed logging out: \(error)&quot;)
    }
&lt;p&gt;})&lt;/p&gt;

&lt;p&gt;8. Update a Complicated Document (push a subdocument into an array): &lt;/p&gt;

&lt;p&gt;var newSubDoc = Document(&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;title&amp;quot;: &amp;quot;newSubDocument&amp;quot;&amp;#93;&lt;/span&gt;)&lt;br/&gt;
var filterDoc = Document([&quot;$push&quot;: Document(&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;arrOfSubDocs&amp;quot;: newSubDoc&amp;#93;&lt;/span&gt;)])&lt;br/&gt;
collection.updateOne(&lt;br/&gt;
    filter: [&quot;_id&quot;: subDoc&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;_id&amp;quot;&amp;#93;&lt;/span&gt; as! ObjectId],&lt;br/&gt;
    update: filterDoc,&lt;br/&gt;
    options: RemoteUpdateOptions(upsert: true),&lt;br/&gt;
    {result in&lt;br/&gt;
        switch result {&lt;br/&gt;
        case .success(_):&lt;br/&gt;
            DispatchQueue.main.async&lt;/p&gt;
{
                // Update UI or perform transation 
            }
&lt;p&gt;        case .failure(let error):&lt;br/&gt;
            let alert = UIAlertController(title: &quot;Update Failed&quot;, message: error.localizedDescription, preferredStyle: .alert)&lt;br/&gt;
            alert.addAction(UIAlertAction(title: &quot;OK&quot;, style: UIAlertActionStyle.default,handler: nil))&lt;br/&gt;
            self.present(alert, animated: true)&lt;br/&gt;
        }&lt;br/&gt;
    }&lt;br/&gt;
)&lt;/p&gt;

&lt;h2&gt;&lt;a name=&quot;Scopeofchanges&quot;&gt;&lt;/a&gt;Scope of changes&lt;/h2&gt;

&lt;h2&gt;&lt;a name=&quot;ImpacttoOtherDocs&quot;&gt;&lt;/a&gt;Impact to Other Docs&lt;/h2&gt;

&lt;h2&gt;&lt;a name=&quot;MVP%28WorkandDate%29&quot;&gt;&lt;/a&gt;MVP (Work and Date)&lt;/h2&gt;

&lt;h2&gt;&lt;a name=&quot;Resources%28ScopeorDesignDocs%2CInvision%2Cetc.%29&quot;&gt;&lt;/a&gt;Resources (Scope or Design Docs, Invision, etc.)&lt;/h2&gt;
</description>
                <environment></environment>
        <key id="600596">DOCS-12034</key>
            <summary>Add code examples to Swift SDK README</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="chris.bush@mongodb.com">Chris Bush</assignee>
                                    <reporter username="tyler.kaye@mongodb.com">Tyler Kaye</reporter>
                        <labels>
                            <label>triage</label>
                    </labels>
                <created>Thu, 6 Sep 2018 17:21:50 +0000</created>
                <updated>Tue, 29 Oct 2019 18:19:01 +0000</updated>
                            <resolved>Tue, 4 Jun 2019 20:33:32 +0000</resolved>
                                                                    <component>Stitch</component>
                        <due></due>
                            <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                    <issuelinks>
                            <issuelinktype id="10320">
                    <name>Documented</name>
                                                                <inwardlinks description="is documented by">
                                        <issuelink>
            <issuekey id="100993">RUBY-705</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="195473" name="sample_sdk.swift" size="4393" author="tyler.kaye@mongodb.com" created="Thu, 6 Sep 2018 17:22:38 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 22 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>jess.mokrzecki@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            5 years, 22 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>chris.bush@mongodb.com</customfieldvalue>
            <customfieldvalue>tyler.kaye@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hu7bjz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr79tr:</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>
                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10555" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Story Points</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hu6xtb:</customfieldvalue>

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