[JAVA-4022] Get Collection validator - how? Created: 23/Feb/21  Updated: 23/Feb/21  Resolved: 23/Feb/21

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: dprutean N/A Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Java driver 3.12.8


Documentation Changes Summary:

In the Java driver I found no method to get the collection validator.
I found no equivalent for db.getCollectionInfos() or db.getCollectionInfos(

{name: "myCollection"}

) inside the Java driver. Could you please add it or I missed it?


 Description   

In the Java driver I found no method to get the collection validator.
I found no equivalent for db.getCollectionInfos() or db.getCollectionInfos({name: "myCollection"}) inside the Java driver. Could you please add it?



 Comments   
Comment by dprutean N/A [ 23/Feb/21 ]

This is the answer, thank you very much! You can close the issue.

Comment by Jeffrey Yemin [ 23/Feb/21 ]

HI pruteanu@gmail.com,

I think what you're looking for is com.mongodb.client.MongoDatabase#listCollections(). So something like:

    Document info = client.getDatabase("test").listCollections().filter(Filters.eq("name", "myCollection")).first();
    System.out.println(info.toJson());

Generated at Thu Feb 08 09:01:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.