Keys in a collection

Is there a way to find the number and names of the keys used in a particular collection, using shell only?
Also, is there a way to define the types of all these key-values ?

The whole point of MongoDB is that it’s schema-less; you do not define these types beforehand :slight_smile:

You can do this, if there are fields that you feel are required in each document. This process is called schema validation.

Is there a way to find the number and names of the keys used in a particular collection, using shell only?

Yes and no.