Can JAVA code judge whether a table in MongoDB cluster is partitioned?

  java, question

Can JAVA code judge whether a table in MongoDB cluster is partitioned?

You can retrieve the collections of config, and the collections in each document in the collections are sharded; At the same time, we can also learn the specific situation of sharded of the collection.Said a little mouthful

The following example is one of the collections documents given in the official document:

bracket
 "_id" : "records.pets",                             --Database name.Collection name
 "lastmod" : ISODate("1970-01-16T15:00:58.107Z"),
 "dropped" : false,
 "key" : {
 "a" : 1                                       --Shard key
 },
 "unique" : false,
 "lastmodEpoch" : ObjectId("5078407bd58b175c5c225fdc")
 bracket

Using Java code to retrieve the above collection, you can learn the required fragmentation information.

For reference.

Love MongoDB! Have Fun!