<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:58:45 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-3086] How to retrieve validator for an existing collection?</title>
                <link>https://jira.mongodb.org/browse/JAVA-3086</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Document validation can be specified when creating a new collection, see &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2008&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;JAVA-2008&lt;/a&gt;, but is there a way to retrieve it after the collection has been created?&lt;/p&gt;

&lt;p&gt;&#160;In mongo Shell this can be easily achieved by running &lt;tt&gt;db.getCollectionInfos({name: &quot;MyTestCollection&quot;})&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;.options.validator;&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;What I miss is a similar method on the &lt;a href=&quot;https://api.mongodb.com/java/3.2/com/mongodb/client/MongoDatabase.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;MongoDatabase&lt;/a&gt; class or a &lt;a href=&quot;https://docs.mongodb.com/manual/reference/command/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Database Command&lt;/a&gt; I can run with the &lt;tt&gt;MongoDatabase.runCommand(...)&lt;/tt&gt; method.&lt;/p&gt;

&lt;p&gt;If there&apos;s currently no way to retrieve that information, would it be possible to turn this question into a feature request?&lt;/p&gt;</description>
                <environment></environment>
        <key id="631639">JAVA-3086</key>
            <summary>How to retrieve validator for an existing collection?</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="zaza">Tomasz Zarna</reporter>
                        <labels>
                    </labels>
                <created>Fri, 9 Nov 2018 12:52:35 +0000</created>
                <updated>Wed, 11 Sep 2019 19:09:44 +0000</updated>
                            <resolved>Fri, 9 Nov 2018 19:17:56 +0000</resolved>
                                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="2057521" author="jeff.yemin" created="Fri, 9 Nov 2018 19:17:56 +0000"  >&lt;p&gt;Happy to hear you&apos;re unblocked.&#160; I agree that your suggestion may be a better API, but on the other hand it&apos;s not all that common for applications to need this functionality.&#160; If you still feel strongly about it, feel free to open a separate feature request for it.&lt;/p&gt;</comment>
                            <comment id="2057479" author="zaza" created="Fri, 9 Nov 2018 18:53:37 +0000"  >&lt;p&gt;That did the trick, thanks Jeff!&lt;/p&gt;

&lt;p&gt;I still think it would be great if I could retrieve the doc with the validator for a specific collection. Now I need to filter the result, looking for a collection I&apos;m interested in i.e. &lt;tt&gt;database.listCollections().filter(Filters.eq(&quot;name&quot;, &quot;MyTestCollection&quot;).first()&lt;/tt&gt;&lt;/p&gt;</comment>
                            <comment id="2056980" author="jeff.yemin" created="Fri, 9 Nov 2018 13:00:32 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=zaza&quot; class=&quot;user-hover&quot; rel=&quot;zaza&quot;&gt;zaza&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you tried &lt;tt&gt;com.mongodb.client.MongoDatabase#listCollections()&lt;/tt&gt;. The document that it returns should include the validator.&#160; If not, please let us know.&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|hu2pvr:</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>