As you develop the model for your MongoDB collection or views, with field-level constraints and indexes, Hackolade dynamically generates corresponding scripts:


The information can be viewed in the MongoDB Script tab:



You may toggle between Create and Update views:


A button lets the user apply to a selected instance the script to create databases, collections with optional $jsonschema validator, indexes, and sharding configuration, and sample data if desired.


For version of MongoDB up to v3.4, the MongoDB script is in aggregation pipeline syntax.  From v3.6 up, the script is in $jsonschema syntax.


You may export these scripts to a JavaScript file with the menu option Tools > Forward-Engineering > MongoDB Script:


The generation of the script can also be triggered with Command-Line Interface.