TylerBrock / mongo-hacker

MongoDB Shell Enhancements for Hackers
tylerbrock.github.io/mongo-hacker
MIT License
1.79k stars 235 forks source link

Describe collections, main methods and helpers #214

Open MisterBalboa opened 3 years ago

MisterBalboa commented 3 years ago

Hi Mongo Hackers! Thanks for the work so far, very helpful. Hereby a functionality that i built for myself and that i use on a daily basis. Open to discussion and modifications..

Description of changes

Added describe function on DBCollection prototype to simulate SQL describe table method. As explained in file, since noSQL is meant to be schemaless, i infer it taking a sample of documents from the collection and building the most complete version i can out of them.

Snapshot example

Collection with 2 documents

Screen Shot 2020-12-02 at 12 11 29

Schema

Screen Shot 2020-12-02 at 12 20 53

Testing

Unit tested most helper functions but as far as i see the project has no test suite.

Software Version(s) tested
mongo shell 4.0.3
MongoDB server
Operating system MacOS Catalina