<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:35:54 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>[GODRIVER-1201] How do we combine filters with the driver?</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-1201</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;Hey folks &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;I am trying to combine some filters with no success, can someone help me out?&lt;/p&gt;


&lt;p&gt;```&lt;/p&gt;

&lt;p&gt;// FindOneByID returns an error on fail, otherwise, it sets the {out} by the result.func FindOneByID(collectionName string, id *primitive.ObjectID, out interface{}, considerArchivedItems bool) error { ctx, _ := context.WithTimeout(context.Background(), 2*time.Second) var filter bson.M&lt;br/&gt;
 if considerArchivedItems { filter = bson.M&lt;/p&gt;
{&quot;_id&quot;: id}
&lt;p&gt; } else { filter = bson.M{&quot;$and&quot;: bson.A{ bson.M&lt;/p&gt;
{&quot;_id&quot;: id}
&lt;p&gt;, bson.M{isArchived: bson.M{&quot;$ne&quot;: false}}}} }&lt;br/&gt;
 return database.Collection(collectionName).FindOne(ctx, filter).Decode(out)}&lt;/p&gt;

&lt;p&gt;```&lt;/p&gt;


&lt;p&gt;Now, I insert an object as archived and trying to get the document. The document is inserted as archived, so I want to consider archived items.&lt;br/&gt;
However, when I pass in the `else`, document can be either archived or not (`false` or `true`), I still get it anyway. So it means that my $and doesn&#8217;t work..&lt;/p&gt;

&lt;p&gt;```&lt;/p&gt;

&lt;p&gt;const ( databaseNameUnitTests&#160; &#160; &#160; &#160; &#160; &#160;= &quot;database_name_unit_tests&quot; databaseCollectionNameUnitTests = &quot;database_name_unit_tests&quot;)&lt;br/&gt;
type Test struct { ID&#160; &#160; &#160; &#160; &#160; *primitive.ObjectID `protobuf:&quot;bytes,1,opt,name=id,proto3&quot; json:&quot;_id,omitempty&quot; bson:&quot;_id,omitempty&quot;` IsArchived&#160; bool&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; `protobuf:&quot;varint,2,opt,name=IsArchived,proto3&quot; json:&quot;is_archived,omitempty&quot; bson:&quot;is_archived,omitempty&quot;` Description string&#160; &#160; &#160; &#160; &#160; &#160; &#160; `protobuf:&quot;varint,3,opt,name=Description,proto3&quot; json:&quot;description,omitempty&quot; bson:&quot;description,omitempty&quot;`}&lt;br/&gt;
// func&#160; &#160; var item Test&#160; &#160; err := mongodb.FindOneByID(databaseCollectionNameUnitTests, insertedID, &amp;amp;item, false)&lt;/p&gt;

&lt;p&gt;```&lt;/p&gt;


&lt;p&gt;The following query from Robo 3T : `db.getCollection(&apos;database_name_unit_tests&apos;).find({$and:[&lt;/p&gt;
{&quot;_id&quot;:ObjectId(&quot;5d2e8afeb0e106fbe0d5af21&quot;)}
&lt;p&gt;,{&quot;is_archived&quot;: {$ne:false}}]})`this works tho, where am I wrong?&lt;/p&gt;</description>
                <environment>Using MAC OS X, Goland</environment>
        <key id="859915">GODRIVER-1201</key>
            <summary>How do we combine filters with the driver?</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</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="13203">Gone away</resolution>
                                        <assignee username="divjot.arora@mongodb.com">Divjot Arora</assignee>
                                    <reporter username="maxime.guittet@say-eyes.com">Maxime Guittet</reporter>
                        <labels>
                    </labels>
                <created>Wed, 17 Jul 2019 16:00:36 +0000</created>
                <updated>Fri, 27 Oct 2023 20:01:23 +0000</updated>
                            <resolved>Thu, 5 Sep 2019 19:22:56 +0000</resolved>
                                                                    <component>BSON</component>
                    <component>CRUD</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="2366478" author="divjot.arora" created="Mon, 12 Aug 2019 12:42:19 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=maxime.guittet%40say-eyes.com&quot; class=&quot;user-hover&quot; rel=&quot;maxime.guittet@say-eyes.com&quot;&gt;maxime.guittet@say-eyes.com&lt;/a&gt;,&#160;&lt;/p&gt;

&lt;p&gt;The &lt;tt&gt;$and&lt;/tt&gt; filter looks fine to me, but there&apos;s a lot of code here. Can you try to create a minimal example that reproduces this issue?&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|hv3von:</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>