How to find the schema of a collection in MongoDB

The last two commands are equivalent to the SQL command below

Describe Table

Open a mongo shell and run the following commands :

MongoDB shell version: 2.4.5
> show dbs
local 0.078125GB
todo 0.453125GB
> use todo
switched to db todo
> show collections
> var schematodo = db.tasks.findOne();
> for (var key in schematodo) { print (key) ; }

Also, on a side note, It is interesting to also note that we at did a web performance test for NOSQL vendors and MongoDB’s site came #7.

Published: September 09 2013

  • Category :