'how to list all the constraints for a mongodb collection?

I have a mongo db collection called students and when I tried to insert a record, I got an about duplicate studentNumber.

I want to run a command to show me all the constraints. I tried db.getCollectionInfos() and this is all it told me about the students collection

        {
                "name" : "students",
                "type" : "collection",
                "options" : {

                },
                "info" : {
                        "readOnly" : false,
                        "uuid" : UUID("70f19e72-bca2-4c86-aa2a-174cfa422d11")
                },
                "idIndex" : {
                        "v" : 2,
                        "key" : {
                                "_id" : 1
                        },
                        "name" : "_id_"
                }
        },

There's no mention that studentNumber is a unique field. Is there another command that I can run to list all the constraints on the students collection?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source